Is there a way to read the total number of product pages for product endpoint

Highlighted
Shopify Partner
15 0 5

When I onboard a new store to my app I need to pull their list of products from the products endpoint.

I'm using the limit=250 querystring to get as many products as I can from the first page, but how do I know if there are more than 250 products? 

 

0 Likes
Highlighted
Shopify Expert
10006 116 1818

Use count first:
https://help.shopify.com/api/reference/product#count

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
0 Likes
Highlighted
Shopify Partner
15 0 5

Perfect - thanks for the pointer!

0 Likes
Highlighted
Tourist
5 0 0

1. When I call /pages/count.json-----I get reply 8

2. When I call Product/Count- I get a reply 6891.

So how is that possible? A page can have 250 products max....So its not making since

 

I am also using Since_id for getting all the products but was only able to get 1683 products instead of 8k+ products.

 

What am i missing?

0 Likes
Highlighted
Shopify Partner
667 47 134
  1. The Pages/Count offers a total number of storefront web pages the Shopify e-com store has.
  2. The Product/Count offers a total number of products the Shopify e-com store has.
  3. The since_id query parameter might very well be deprecated, since Shopify has implemented cursor-based pagination for retrieving "pages" of results.

 

Highlighted
Tourist
5 0 0

Oh boy! Thanks:)

Now what is the best way to retrieve all the products?

0 Likes
Highlighted
Shopify Partner
667 47 134

I would suggest using the GraphQL API, as opposed to the REST API. Since the former is more efficient and results in less hoops to jump through. Here's a post along those lines --> https://community.shopify.com/c/Shopify-APIs-SDKs/How-to-retrive-all-the-products-of-shop-using-Grap....  

Highlighted
Shopify Expert
4265 32 434

And if your goal is to have all products, the bulk download is handy. You get a JSONL file which makes playing with those products a breeze.

 

https://shopify.dev/tutorials/perform-bulk-operations-with-admin-api

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
0 Likes