Partner API / Pagination
Pagination
List endpoints return pages, newest first, with a cursor.
Ask for up to 100 items with limit. When there are more, the response has a next_cursor; pass it back as cursor for the next page. When next_cursor is null, you have everything.
import os, requests
url = "https://api.affiliatepipe.com/v1/conversions"
headers = {"Authorization": "Bearer " + os.environ["AP_KEY"]}
params, rows = {"limit": 100}, []
while True:
page = requests.get(url, headers=headers, params=params).json()
rows += page["data"]
if not page["next_cursor"]:
break
params["cursor"] = page["next_cursor"]