Pagination
List endpoints return newest first:
{ "object": "list", "data": [ ... ], "has_more": true, "url": "/v1/orders" }
limit— 1 to 100, default 20.starting_after— theidof the last object you got. Pass it to get the next page.created_gte,created_lt— Unix seconds, to fetch a time window (on lists that support them).
params = {"limit": 100}
while True:
page = requests.get(f"{API}/v1/orders", params=params, headers=auth).json()
for order in page["data"]:
handle(order)
if not page["has_more"]:
break
params["starting_after"] = page["data"][-1]["id"]
Cursors are stable: new objects don't shift pages you're walking.