How to get all product

Highlighted
Shopify Partner
2 0 0

in shopify api documentation i am only get maximum 500 product, how to get more than 500 product?

0 Likes
Highlighted
Shopify Partner
53 0 9

You haven't specified what language your are using but i usually do the following:

  1. Get the total count of products (/admin/products/count.json)
  2. Divide by the maximum number of products per request (i usually do 250) - this gives you the total number of pages to loop through
  3. Loop from 1 to 'x' number of pages
  4. Call /admin/products.json?limit=250&page=[loop iteration]

What i usually do is add the results from each loop into a single array and then do whatever processing i need.

In PHP, the code would be like this:

$count = $client->call("GET", "/admin/products/count.json");

if ($count > 0) {
  $pages = ceil($count / 250);
  for ($i=0; $i<$pages; $i++) {
    $results = $client->call("GET", "/admin/products.json?limit=250&page=".($i+1));
    foreach ($results as $result) {
       // your processing code here
    }
  }
}

 

2 Likes
Highlighted
With the new cursor-based pagination, how to get all products?
SPO - SEO App to research keywords & edit social link preview
1 Like