Get Started With OCAPI 23.2
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: the Shop API allows a client to interact with the system as a shop customer or as an agent shopping on behalf of a customer, the Data API gives create/read/update/delete access to system resources, and the Meta API is used to retrieve 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.
The three APIs are used as follows:
- Use the Shop API to access public shop information such as product and catalog data, images, recommendations, and prices or promotions: use the Shop API. 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.
- Use the Shop API in the context of a registered or guest customer to interact with the system as a shop 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.
- Use the Shop API in the context of a Business Manager user to interact with the system as an agent on behalf of a shop customer, 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.
- 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: