DocumentationAPI v1
Documentation/Guides/Syncing with changes
Guide

Syncing with changes

Keep a copy up to date without re-reading every list.

/v1/changes lists everything added or changed since a cursor: matches, players and events, oldest first. Each row says what changed and whether it is new or updated.

The loop

Start without since to get the last day. Store meta.next_cursor, and next time pass it as since. Filter to one kind with kind=match, player or event.

import os, requests, json, pathlib

state = pathlib.Path("since.txt")
params = {"limit": 500}
if state.exists():
    params["since"] = state.read_text()

r = requests.get("https://api.dartsapi.com/v1/changes", params=params,
    headers={"Authorization": f"Bearer {os.environ['DARTS_API_KEY']}"}).json()
for change in r["data"]:
    print(change)
if r["meta"]["next_cursor"]:
    state.write_text(r["meta"]["next_cursor"])