Started building a price comparison tool last month. Needed product data from multiple sources so I hooked up a bunch of APIs.
First vendor looked solid. Clean docs, good examples, test endpoint worked great.
Production returned empty arrays
Dev endpoint gave me perfect JSON:
{
"status": "success",
"products": [
{"id": "123", "price": 29.99, "stock": 45}
]
}
Production?
{
"status": "success",
"products": []
}
Status says success. Array is empty. Zero errors.
Spent an hour checking my request params. Auth headers looked fine. Rate limits not hit. Nothing wrong.
Support told me dev and prod are different
Called them after wasting that hour. "Oh yeah production data is paginated, dev isn't."
Not in the docs anywhere. Test environment doesn't paginate. Production does.
import requests
url = "https://api.vendor.com/products"
headers = {"Authorization": f"Bearer {token}"}
all_products = []
page = 1
while True:
response = requests.get(url, headers=headers, params={"page": page})
data = response.json()
if not data.get("products"):
break
all_products.extend(data["products"])
page += 1
print(f"Got {len(all_products)} products")
Added the pagination loop. Got 3000+ products instead of zero.
Never trust test environments match production now. Always ask support about differences. Also check for pagination even when docs don't mention it cause a lot of APIs just default to page 1 with like 50 results max.
Still annoyed about it honestly.
Top comments (0)