I’m trying to implement pagination in products API. The programing language is PHP
Pagination with since_id
In the first iteration, the endpoint is:-
https://shop-domain.myshopify.com/admin/api/2021-07/products.json?limit=2
and the second iteration the endpoint is:-
https://shop-domain.myshopify.com/admin/api/2021-07/products.json?limit=2&since_id={last_product_id}
and so on…
I have a total of 65 products. if my limit is 2 then the total iteration will be 33.
but using this technique I will get only 20 products.
After debugging the code I saw an Issue. That is, After 10 times iteration, we get the first product’s id that’s why we get the repeated product.
Pagination with a link header
Also, I am trying to implement pagination using the Link header.
In the first iteration, the endpoint is:-
https://shop-domain.myshopify.com/admin/api/2021-07/products.json?limit=2
After getting the response of the first iteration, I do not get any Link header.
How to solve this problem. Please share with me some suggestions.