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

Jonathan_H
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
Jason
Shopify Expert
10253 142 1940

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

I jump on these forums to help and share some insights. Not looking to be hired, and not looking for work.

Don't hand out staff invites or give admin password to forum members unless absolutely needed. In most cases the help you need can be handled without that.


★ http://freakdesign.com.au ★
0 Likes
Jonathan_H
Shopify Partner
15 0 5

Perfect - thanks for the pointer!

0 Likes
BbuyTech
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
Greg_Kujawa
Shopify Partner
1016 83 226
  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.

 

BbuyTech
Tourist
5 0 0

Oh boy! Thanks:)

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

0 Likes
Greg_Kujawa
Shopify Partner
1016 83 226

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....  

HunkyBill
Shopify Expert
4472 45 484

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