Product Recommendations API reference
The Product Recommendations API can be used to recommend related products for a given product. To learn more about how recommendations are made and the associated limitations, refer to Product recommendations.
To learn how to show product recommendations in your theme, refer to Product recommendations.
All Ajax API requests should use locale-aware URLs to give visitors a consistent experience.
The Shopify Search & Discovery app enables users to customize product recommendation and search results, which can impact results from storefront search and the Ajax Product Recommendations API. To learn about how these results can be impacted, visit the Shopify Help Center.
Anchor to GET /{locale}/recommendations/products.jsonGET /{locale}/recommendations/products. json
The following example request retrieves the recommended products for a specific product:
Anchor to Query parametersQuery parameters
Query parameter | Required | Description |
---|---|---|
product_id | Yes | The unique product ID of the product that you want to show recommended products for. |
limit | No | Limits the number of results. The value can range from |
intent | No | The recommendation intent that is used to generate product recommendations. You can use The accepted values are |
Example request object
Example request using Fetch
Anchor to Products responseProducts response
The following example is a response to a successful request to the /{locale}/recommendations/products.json
endpoint:
Example product response
Anchor to Error responsesError responses
When a request to the /{locale}/recommendations/products.json
endpoint is unsuccessful, one of the following error responses is returned:
Anchor to Invalid parameterInvalid parameter
In the absence of a product_id
parameter, the endpoint returns the following error:
If intent
isn't one of related
or complementary
, then the endpoint returns the following error:
Anchor to Product not foundProduct not found
If the product_id
is for a product that doesn't exist, or that isn't published in the Online store channel, then the endpoint returns the following error:
Anchor to GET /{locale}/recommendations/productsGET /{locale}/recommendations/products
The following example request retrieves the HTML from a section rendered with product recommendations for a specific product.
Anchor to Query parametersQuery parameters
Query parameter | Required | Description |
---|---|---|
product_id | Yes | The unique product ID of the product that you want to show recommended products for. |
limit | No | Limits the number of results. The value can range from |
section_id | Yes | The unique section ID of the section file that you want to render with product recommendations. |
intent | No | The recommendation intent that is used to generate product recommendations. You can use The following values are accepted: |
Example request object
Example request using Fetch
Anchor to Section responseSection response
The response to a successful request to the /{locale}/recommendations/products
endpoint.
The section response contains the HTML of the provided section rendered with the recommendations
object containing the recommended products for the specified product.
For example, the following section would generate the following section response:
Example section
Example section response
Anchor to Error responsesError responses
When a request to the /{locale}/recommendations/products
endpoint is unsuccessful, one of the following error status codes is returned:
Status code | Description |
---|---|
404 |
|
422 |
|
Anchor to Tracking conversions for product recommendationsTracking conversions for product recommendations
The url
property for each product
in the products response contains URL parameters that lets you build a conversion funnel that can be tracked by using reports in Shopify. Similarly, the Liquid url
property returned for recommendations.products
contains this tracking information as well. The URL uses the following format:
To learn more about product recommendation reports, see Product recommendation conversion over time.