Core concepts
Pagination
Cursors, not offsets. On a feed where records arrive while you are reading it, an offset quietly skips records and a cursor does not.
Why not page numbers
Offset pagination assumes the result set holds still. Emergency data does not. If three new incidents arrive between your request for page 1 and your request for page 2, everything shifts down by three and you never see the three that moved across the boundary. Nothing errors. You simply have a gap.
A cursor points at a position in the data rather than a count from the start, so new arrivals cannot shift it.
How to page
Ask for a page. If the response carries a nextCursor, pass it back as cursor to get the next one. When it is absent, you have reached the end.
# first page curl "https://emergencyapi.com/api/v1/incidents?state=nsw&limit=100" \ -H "Authorization: Bearer YOUR_API_KEY" # next page, using nextCursor from the previous response curl "https://emergencyapi.com/api/v1/incidents?state=nsw&limit=100&cursor=eyJ1cGRhdGVkX2F0IjoiMjAyNi0wNy0yNlQwMDowMDowMFoiLCJpZCI6Im5zdy1yZnMtMTIzIn0" \ -H "Authorization: Bearer YOUR_API_KEY"
- limit
- Records per page. Defaults to 100, maximum 500. A value above the maximum is a 400, not a silent clamp, so you never think you asked for more than you received.
- cursor
- An opaque base64url token encoding a position. Treat it as opaque: its contents are an implementation detail and a malformed cursor returns 400.
- nextCursor
- Present only while more records exist. Its absence is the end-of-results signal, so loop until it is missing rather than until a page comes back short.
One correct loop
Stop on the absent cursor, not on an empty page. A full page can legitimately be the last one.
import requests
url = "https://emergencyapi.com/api/v1/incidents"
headers = {"Authorization": "Bearer YOUR_API_KEY"}
params = {"state": "nsw", "limit": 100}
incidents = []
while True:
r = requests.get(url, headers=headers, params=params, timeout=30)
r.raise_for_status()
body = r.json()
incidents.extend(body["features"])
cursor = body.get("nextCursor")
if not cursor:
break
params["cursor"] = cursor
print(f"{len(incidents)} incidents")