Get Started With OCAPI
The Open Commerce API (OCAPI) enables you to access resources using HTTP requests and HTTP responses. Each resource is addressed by its unique URL, which includes the API version. Data is transported using request or header parameters, or within the request body as a JSON document with a defined structure.
OCAPI is divided into different APIs:
- Shop API: allows a client to interact with the system as a shop customer or as an agent shopping on behalf of a customer.
- Data API: gives create/read/update/delete access to system resources.
- Meta API: retrieves a formal description of the Open Commerce API, including custom attributes.
The following steps are recommended to start using the APIs:
- Read about the HTTP Methods used to request resources and the HTTP status codes and faults used in the responses.
- A client ID is mandatory for all requests. Read get a client ID for your application client.
- Review the URL Schema used in the requests.
- Read about the Resource States framework used to ensure data consistency.
- Learn about the need to configure Open Commerce API Settings to authorize the usage of the resources, globally or for one site.
Use the Shop API to:
- Access public shop information such as product and catalog data, images, recommendations, and prices or promotions. Because in this case you're probably interacting with the system in the context of a guest customer, authentication isn’t required. However, as with every request, the system checks the Open Commerce API Settings to verify that the client ID you provide is allowed to use the specified resource.
- Interact with the system as a registered or guest customer, for example: to access customer-specific data or to create and submit a basket. Authenticate the customer by obtaining a JWT to be passed in each request.
- Interact with the system as an agent on behalf of a customer in the context of a Business Manager user, for example: to access customer-specific data or to create and submit a basket. Authenticate the user by obtaining an OAuth token for a Business Manager user to be passed in each request. The system checks both the Open Commerce API Settings and the required Business Manager permissions before allowing the request.
- Enable personalized headless storefront experiences, such as customized promotions, pricing, and shipping methods. Set a shopper's context to enable personalized experiences using the Shopper Context API.
Use the Data API to access or update merchant resources such as coupons, customer lists, slot configurations or content. Authenticate the requests by obtaining an OAuth token for your client ID or for a Business Manager user, to be passed in each request.
Use the Meta API to access details about the resources and documents provided by the Open Commerce API.
For additional learning material, see the following:
- Introduction to OCAPI (video)
- Introduction to OCAPI (slides)
- OCAPI authorization and sample call overview using Postman (video)
- OCAPI Performance Best Practices FAQ
- Postman collection, environment. and OCAPI settings (GitHub repository)