OCAPI versus storefront controllers for headless or app access
Key Takeaway
OCAPI requests skip the web tier cache, and storefront controllers are stateful. A headless or app client must use caching well and reuse its session (the cookie for controllers, a JWT for OCAPI), or it can slow the whole instance.
An external client, such as a mobile app or a headless front end, can reach B2C Commerce through OCAPI or through custom storefront controller endpoints. The two differ in caching, session handling and resource cost. Your choice affects the performance of the whole instance, not just the app.
Ways to reach B2C Commerce
B2C Commerce has two REST API products, OCAPI and SCAPI. Storefront requests are handled by controllers or pipelines.
| OCAPI | SCAPI | |
|---|---|---|
| Full name | Open Commerce API | B2C Commerce API |
| Introduced | 2014 | 2020, for headless commerce |
| Status | Maintenance-only mode, but not going away | Recommended by Salesforce for new customers, new projects and major refactoring work |
OCAPI includes the Shop API, Data API and Meta API.
SLAS can also authenticate shoppers for OCAPI, so one shopper token works across both APIs. Using SLAS with OCAPI still requires Account Manager.
SCAPI Custom APIs expose custom script code as a REST API under SCAPI. A Custom API has a smaller back-end resource footprint than a controller-based endpoint.