uCommerce includes full API reference documentation and lots of helpful articles to help you build your e-commerce site as effortlessly as possible.
Learn how the uCommerce APIs are structured and what to expect from working with the top-level APIs of the platform.
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 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.
All the Libraries for doing various operations are located in the namespace
UCommerce.Api that are located in the assembly
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:
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
IUrlService. Those are all dependencies that the APIs use to perform different operations.
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:
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
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.