Pagination
4 min
list endpoints return a consistent envelope so you can page through results the same way everywhere the list envelope only list/collection responses are wrapped single resources are returned bare (the object is the response body directly) { "data" \[ { " " " " }, { " " " " } ], "pagination" { "next cursor" null, "has more" false } } data — the array of resources for this page has more — true if there are more results after this page next cursor — an opaque cursor for the next page, or null when there are no more results every list returns this envelope from launch — even endpoints that don't paginate today return next cursor null and has more false build for it once and it works across the api paging through results pass the next cursor value back as the next query parameter to fetch the following page treat the cursor as opaque — don't parse or construct it curl "https //api mailfloss com/v1/jobs?per page=25" \\ h "authorization bearer your api key" \# > { "data" \[ ], "pagination" { "next cursor" "zxhhbxbszq", "has more" true } } curl "https //api mailfloss com/v1/jobs?per page=25\&next=zxhhbxbszq" \\ h "authorization bearer your api key" a typical loop — keep going until has more is false import requests session = requests session() session headers\["authorization"] = "bearer your api key" url = "https //api mailfloss com/v1/jobs" params = {"per page" 100} jobs = \[] while true page = session get(url, params=params) json() jobs extend(page\["data"]) if not page\["pagination"]\["has more"] break params\["next"] = page\["pagination"]\["next cursor"] page size control page size with per page defaults vary by endpoint, and the maximum is 100 endpoint default per page get /v1/jobs 25 get /v1/users 25 get /connections/{id}/blacklist and /whitelist 50 requesting more than 100 is capped at 100 see the api reference for the per endpoint default
