Base URL and Request Formation
This guide covers how to construct well-formed requests to the B2C Commerce API that include all the required parameters.
The base URL for all requests to the B2C Commerce API follows a pattern for identifying your B2C Commerce instance and directing your request to the correct API family. To understand the pattern, let’s look at the base URL with placeholders (enclosed in double curly braces) for the parts of the URL that vary depending on your instance and API family:
Now let’s replace the placeholders with the following example values:
Placeholder | Value |
---|---|
{{shortCode}} | kv7kzm78 |
{{apiFamily}} | product |
{{apiName}} | shopper-products |
{{organizationId}} | f_ecom_zzte_053 |
With example values, the base URL looks like this:
The short code and organization ID in our examples belong to the demo sandbox. To learn how to look up these values for your own B2C Commerce instance, see the Configuration Values guide.
Now let’s combine the base URL with the getProduct endpoint to get product information for product ID 25695327M
on the RefArchGlobal
site:
Notice that the name of the endpoint, getProduct
, doesn’t appear in the URL. The getProduct
string is only used as an identifier for the endpoint in the documentation. The URL for that endpoint is formulated by adding products/{{productID}}
to the base URL.
The full URL in our endpoint example also includes a required query parameter, siteId
, to the query string.
Many endpoints have required query parameters. For the Shopper APIs, the siteId
parameter is often required.
To make a valid request, a well-formed URL is not sufficient. Most endpoints have additional requirements for HTTP headers and the request body (usually in the form of a JSON object). Always check the API reference to learn the exact requirements of each endpoint.
You’ve completed the last guide in the Get Started series!
To learn about the B2C Commerce API in more detail, we recommend exploring the following topics:
To learn from other Commerce API users, see the Community guide.