Get a list of ALL Products (not just the first 50)

Solved
Highlighted
Excursionist
15 1 1

If I use the Products API it only returns 50. I realize this is a limit, but I new the whole list returned or a way of looping through and get the whole list 50 at a time.  How can this be done?  What is the API call?

0 Likes
Highlighted

You need to use pagination to loop through all of the products and store them to a variable or database.

How you do this will depend on if you are using the rest api or the graphql api (and the development stack you are using):

 

rest pagination:

https://help.shopify.com/en/api/guides/paginated-rest-results

 

graphql pagination:

https://help.shopify.com/en/api/getting-started/shopify-and-graphql/pagination

0 Likes
Highlighted
Excursionist
15 1 1

Do you know if the GraphQL API allows for a single query to return ALL the products?  or is it still throttled by pagination?

0 Likes
Highlighted

The pagination is based off of request tokens, so the answer on this depends on what information you are trying to get and how many products you have.

 

You generally start with 1000 tokens:

https://help.shopify.com/en/api/graphql-admin-api/graphql-admin-api-rate-limits

1 Like
Highlighted
Excursionist
15 1 1

This is an accepted solution.

I discovered the using the "products.json?since_id=<last id>"  is another way to do this.  First set <last id> to be 0 and then put in a loop such that <last id> is set to the last product id returned, exit the loop when the returned product.count is 0.

1 Like