
API docs said pagination worked. It didn't.
API docs said pagination worked. It didn't. Was integrating this ecommerce API last week for product data. Docs say pagination works with offset and limit parameters. Seemed simple enough. What the docs showed response = requests . get ( ' https://api.example.com/products ' , params = { ' offset ' : 0 , ' limit ' : 100 } ) Perfect right? Just loop and increment offset by 100 each time. The problem Worked fine for first 200 products maybe 300. Then started getting duplicates. Then missing products entirely. Offset 400 returned same stuff as offset 300. Offset 1000 gave me products from offset 200. Thought my code was broken. Checked logs for 2 hours. Nothing wrong on my end. Turns out API was sorting by relevance not ID. Every time I hit it the order changed slightly because products got sold or restocked. So offset 400 wasnt actually the 400th product anymore, it was whatever happened to be 400th at that exact moment. Docs never mentioned this. Support didnt know either when I asked. W
Continue reading on Dev.to Python
Opens in a new tab



