DocumentationAPI v1
Documentation/Guides/Pagination
GuideFree

Pagination

Two ways through a long list, and when to use each.

Every list returns at most limit rows: 50 unless you ask, and at most 200. Fixtures and the change feed allow more, 100 by default and up to 500.

Cursor, for walking a whole set

When there is more, meta.next_cursor holds where to carry on. Pass it back as cursor exactly as it came, and stop when it comes back null. A cursor pages by position in the sort, so the ten-thousandth page is as quick as the first, and a match arriving while you walk cannot shift a row onto two pages.

import os, requests

url = "https://api.dartsapi.com/v1/results"
headers = {"Authorization": f"Bearer {os.environ['DARTS_API_KEY']}"}
params = {"player_id": "pl_VEB8HM", "limit": 200}

while True:
    page = requests.get(url, headers=headers, params=params).json()
    for match in page["data"]:
        print(match["played_on"], match["round"])
    if not page["meta"]["next_cursor"]:
        break
    params["cursor"] = page["meta"]["next_cursor"]

Page, for a pager in a UI

Lists that show a pager to people also take page, counting from 1. Use it where someone clicks "page 3". Use page or cursor, not both.