Rest Admin API - Products

AI-generated summary

Issue: Intermittent pagination failure in Shopify REST Admin API when syncing products.

  • Workflow: First call the products count endpoint (/admin/api/2023-01/products/count.json), then fetch all products (/admin/api/2023-01/products.json) with limit=50 and use the HTTP “Link” header to retrieve the next page.
  • Problem: The “Link” header is missing on some pages at random across attempts, breaking the pagination loop. The user asks for causes or solutions.

Context: The “Link” header is an HTTP pagination mechanism that normally provides the URL for the next page of results.

Update/Suggestion: Another participant recommends using GraphQL for potentially easier pagination, specifically the QueryRoot.products connection, which supports paginated retrieval of products.

Outcome/Status: No confirmed fix or explanation for the REST “Link” header inconsistency was provided. The only actionable suggestion is to switch to GraphQL for pagination. The thread remains open with the core REST issue unresolved.

I’m using get products count API to get total products ( /admin/api/2023-01/products/count.json ),

then use get all products ( admin/api/2023-01/products.json ) to loop and sync all products.

With limit 50 per page, I am getting next page products by using “link” parameter in header .
I realize that it will not include link in header at some random pages. It is not fixed for every attempt.
Would like to check on this? Anyone has experiences / solutions for this?

The pagination experience might be a little easier with GraphQL. You could use QueryRoot.products to get a list of the shop’s products, which can be paginated.