Documentation

Ucommerce includes full API reference documentation and lots of helpful articles to help you build your e-commerce site as effortlessly as possible.

Topics Payment Providers
v7.18

Ucommerce API Overview

Learn how the Ucommerce APIs are structured and what to expect from working with the top-level APIs of the platform.

The 80/20 APIs

The top-level APIs of Ucommerce are lovingly called 80/20 APIs because they are designed for very specific purposes: ease of use, and discoverability, which means that they are not designed for ultimate flexibility.

They are appropriate for maybe 80% of what you want to do when building an online store, but for the last 20% or to get more flexibility, you will have to use a lower level API.

The premise for the platform is that you can make Ucommerce do whatever you need. If you can't find what you need, you can always move down a level of abstraction. This is especially useful when you need to override behaviors of the API for more advanced scenarios.

The 80/20 APIs are structured into two different categories:

  • Libraries
  • Context classes

Libraries are used to do operations on the front-end such as search, apply promocodes or add products to the basket.

Context classes are used to retrieve the current context of the site such as the current store, category or basket.

Libraries are context aware and will use the context to make it simpler to call methods on them, e.g. you don't have to specify which customer to get the basket for as that's determined by the order context.

Libraries

All the Libraries for doing various operations are located in the namespace UCommerce.Api that is located in the assembly UCommerce.dll.

Those are all the static APIs you'd want to use when you want to add products to the basket, get available shipping methods, execute the basket pipeline and so on.

Available libraries are:

  • CatalogLibrary
  • TransactionLibrary
  • SearchLibrary
  • MarketingLibrary

Using libraries is meant to be as straightforward as possible:

    
    	// Load product with SKU "mySku"
    	Product mySku = CatalogLibrary.GetProduct("mySku")
    
    	// Add "mySku" to basket
    	TransactionLibrary.AddToBasket(1, "mySku");
    

The APIs are simple abstractions on top of the actual platform implementation, which consists of a number of services such as IPricingService, IUrlService. Those are the dependencies that the APIs use to perform different operations.

Context

To help you know what a customer is currently browsing in your store, context is exposed via SiteContext. You will know which store, catalog, category, and product the customer is currently browsing and also what the customer has added to her basket.

Available context classes are:

  • CatalogContext
  • OrderContext
  • CurrentCulture

The SiteContext may be used to retrieve the current context of the site e.g. getting the current product and more:

    
    	UCommerce.EntitiesV2.Product currentProduct = UCommerce.Runtime.SiteContext.Current.CatalogContext.CurrentProduct;
    	UCommerce.EntitiesV2.Category currentCategory = UCommerce.Runtime.SiteContext.Current.CatalogContext.CurrentCategory;
    

Context is exposed in the namespace UCommerce.Runtime.

Summary

To make it easy to develop common features of online stores Ucommerce provides APIs in the form of libraries and context out of the box, which enables you to get the job done without hassle.

Should you need more control or different behavior from the APIs, you can override the default behavior in APIs and services to tailor the experience to whatever is required.