Access a community of over 900,000 Shopify Merchants and Partners and engage in meaningful conversations with your peers.
I need to get all the products in my shop, but when I try to print them, having the limit of 250 per call, I realized that there were no products, the rest call with the since_id does not seem to work.
To test I made the request for the first 10 products, and then I tried to get them 5 to 5 and this was the result.
these are the top 10 products ids:
then I made 2 calls to get the first 5 products in the first, and the next 5 in the second using the since_id:
can see the first 5 are correct, but the next 5 do not match. What am I doing wrong ?
Solved! Go to the solution
This is an accepted solution.
Hey there @Giancarmelo
Had you tried the first call including since_id=0 along with those fields when trying to get all the products on your store at the beginning? So something like this would return the first ten products I created on my store - api/2021-10/products.json?fields=id,handle,variants&since_id=0&limit=10
Then, if I look at those ten products, and take the fifth product's ID, and then try this following GET. Like so - api/2021-10/products.json?fields=id,handle,variants&since_id={the_fifth_product's id}&limit=5
I diff my results from my first call of ten against my second call for the next 5 after the fifth ID, and the ID's all match ok. I think your mismatch could have something do with the default, products are returned in ascending order by title in the Products API when since_id is not specified.
There's some further docs here if you need them. Let me know how that goes!
This is an accepted solution.
Hey there @Giancarmelo
Had you tried the first call including since_id=0 along with those fields when trying to get all the products on your store at the beginning? So something like this would return the first ten products I created on my store - api/2021-10/products.json?fields=id,handle,variants&since_id=0&limit=10
Then, if I look at those ten products, and take the fifth product's ID, and then try this following GET. Like so - api/2021-10/products.json?fields=id,handle,variants&since_id={the_fifth_product's id}&limit=5
I diff my results from my first call of ten against my second call for the next 5 after the fifth ID, and the ID's all match ok. I think your mismatch could have something do with the default, products are returned in ascending order by title in the Products API when since_id is not specified.
There's some further docs here if you need them. Let me know how that goes!