Select version
v7.7 v7.6 v7.5 v7.3 v7.1 v7.0 v6.8 v6.7 v6.6 v6 v5 v4 v3 v2

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 becasues they are designed for very specific purposes, ease of use, and discoverability, which means that they are not designed for ultimate flexiblity.

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 flexiblity you'll 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 within 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 are located in the assembly UCommerce.dll.

Those are all the static APIs you'd want to use when you want to add stuff the basket, get avaiable 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 all 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'll 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 retrieve the current context of the site e.g. like 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 enable 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.

uCommerce Aps - Studsgade 29B - 8000 Aarhus C - Denmark
Phone +45 61 799 997 - Email info@ucommerce.dk uCommerce logo