All posts

Shopify Product Recommendations API: Endpoint & Examples

By Mehmet Tekin5 min readupdated
Shopify Product Recommendations API: Endpoint & Examples

Most Shopify recommendations tutorials start with OAuth: create an app, get a client ID, exchange a code for a token, then call the API. You do not need any of that for the storefront endpoint. It is a public request, it takes no token, and it returns the same product objects your theme already knows how to render.

This guide is the short version: the two storefront endpoints, the parameters that matter, the response shape, and where authentication actually enters the picture.

The two storefront endpoints

Shopify exposes recommendations in two forms, and they solve different problems.

Endpoint Returns Use it when
/{locale}/recommendations/products.json JSON: { intent, products } You are rendering the cards yourself, in a custom section or an island
/{locale}/recommendations/products HTML for a section Your theme already has a recommendations section and you want Shopify to render it

Both take a product_id, an optional limit and an optional intent. Neither needs an access token.

The JSON request

curl "https://your-store.myshopify.com/recommendations/products.json?product_id=1234567890123&limit=4&intent=related"

The locale prefix is optional. Including it keeps the response in the language the visitor is browsing — the docs recommend locale-aware URLs for that reason.

You can make this request without a terminal: the recommendations inspector fetches it for any product URL and shows the JSON it gets back, including when the list comes back empty and why.

Parameters:

Parameter Required What it does
product_id Yes The product to base recommendations on. It must be published to the Online Store channel.
limit No 1 to 10. Defaults to 10.
intent No related or complementary. Defaults to related.

The response is an object with the intent you asked for and a products array:

{
  "intent": "related",
  "products": [
    {
      "id": 35,
      "title": "Gorgeous Silk Coat",
      "handle": "gorgeous-silk-coat",
      "url": "/products/gorgeous-silk-coat?pr_choice=default&pr_prod_strat=copurchase&pr_rec_pid=35&pr_ref_pid=17&pr_seq=alternating",
      "price": 380000,
      "available": true,
      "featured_image": null
    }
  ]
}

Two things to notice:

  • Prices are in cents, as integers. 380000 is $3,800.00. Format them with the store's currency, not with a hard-coded symbol.
  • Do not strip the query string from url. Shopify appends pr_* parameters that its own recommendation reports use. Rebuilding the URL from the handle loses the attribution.

An empty products array is a valid answer, not an error. It usually means the product is not published to the Online Store channel, the store is too new for related recommendations, or no complementary products have been set.

The intent parameter is the only thing that changes the strategy:

  • related returns products similar to the one being viewed — "You may also like", "Similar items". Shopify generates this from the store's data, so a small or new store can get a short list or none.
  • complementary returns products meant to be bought together — "Frequently bought together", "Pair it with". This is not inferred from purchase history: it comes from the complementary products the merchant has set, usually through Shopify Search & Discovery. If nothing is set, the list is empty.

That distinction matters for a theme: a "You may also like" block should use related, and a "Complete the set" block should use complementary. Swapping them produces a section that looks broken without throwing an error.

Render it in a theme

If your theme already has a recommendations section, the section-rendering endpoint is less code than the JSON path. Give the section an id, then request it with the product id:

const target = document.querySelector('.product-recommendations');

fetch(
  `${window.Shopify.routes.root}recommendations/products?product_id=${productId}&limit=4&section_id=product-recommendations&intent=related`
)
  .then((response) => response.text())
  .then((html) => {
    const parsed = document.createElement('div');
    parsed.innerHTML = html;
    const section = parsed.querySelector('.product-recommendations');
    if (section && section.innerHTML.trim()) {
      target.innerHTML = section.innerHTML;
    }
  });

The section file receives a Liquid recommendations object, and the guard is the important part:

{%- if recommendations.performed? -%}
  <div class="product-recommendations">
    {%- if recommendations.products_count > 0 -%}
      <h2>You may also like</h2>
      <ul>
        {%- for product in recommendations.products -%}
          <li><a href="{{ product.url }}">{{ product.title }}</a></li>
        {%- endfor -%}
      </ul>
    {%- endif -%}
  </div>
{%- endif -%}

recommendations.performed? is false on the first page render, when the section is included normally. That is what stops the section from doing the work twice: the first render is a placeholder, and the fetch fills it.

If you are building an app

The public endpoints are for storefronts. An app that needs recommendations for arbitrary products, including products not published to the Online Store, uses the Admin API instead — and that one does need authentication:

query {
  productRecommendations(productId: "gid://shopify/Product/1234567890123") {
    id
    title
    handle
  }
}

The app needs the read_products scope. The Admin API version also returns a list rather than a section, and it is subject to the app's own rate limits, so it is not a drop-in replacement for the storefront call.

For a custom storefront (Hydrogen, or any headless build), the Storefront API has a productRecommendations query behind a public Storefront access token. That is the third path, and the one to use when there is no Liquid theme at all.

Cache it, and keep the limit small

Recommendations are expensive to compute and change slowly. A call on every product view is wasted work.

  • Cache per product and intent for a few minutes. The list does not need to be fresher than the catalogue.
  • Request four to eight, not ten. A recommendations row that scrolls off the screen is bandwidth you paid for.
  • Do not call it on the homepage. It needs a product id. For a homepage row, use a collection or a manual list.
  • Expect fewer results than you asked for. Layouts that assume four cards break on a store that returns one.

If you are a merchant

You do not need any of this. Your theme already has a recommendations section — usually "You may also like" on the product page — and it uses this same endpoint under the hood. Check the theme editor before installing an app for it.

The case for changing something is narrow: you want a different placement, a different intent (complementary rather than related), or a row that is not a product carousel. If you want a number on the product page that is about demand rather than similarity, how to show units sold on a Shopify product page is the same integration shape with a different data source.

FAQ

Do I need an access token for the Shopify recommendations API? No. The Ajax endpoint at /recommendations/products.json is a public storefront request and takes no token. The Admin API and Storefront API versions do.

How many product recommendations can I request? Between one and ten. The limit parameter defaults to ten, and the endpoint can return fewer than you ask for when the store has little sales history.

What is the difference between related and complementary recommendations? Related products are similar to the product being viewed and are generated from the store's data. Complementary products are pairs the merchant has set, usually through Shopify Search & Discovery, and the list is empty when nothing has been set.

Why does the recommendations endpoint return an empty list? The product may not be published to the Online Store channel, the store may not have enough data for related recommendations, or no complementary products have been configured. The endpoint returns an empty products array rather than an error in those cases.

Can I use the recommendations API on the homepage? Not directly. It requires a product_id, so it is built for product pages. For the homepage, use a collection, a manual list, or the Storefront API's productRecommendations query with a product ID you choose.

Updated by Mehmet Tekin, 20 November 2026. Sources: Shopify's Product Recommendations API reference and the Storefront API productRecommendations query, read 20 November 2026. I build Sold So Many, a Shopify social proof app; it is not a recommendations app, which is why this post is a reference rather than a pitch.

Written by

Mehmet Tekin

Founder, Sold So Many

I build Sold So Many, a Shopify app that shows shoppers real sold counts and live cart activity from a store's own orders. I have been shipping Shopify apps since 2024 and write here about social proof, urgency and conversion.

All posts