Lists and paging
Every call that returns many items, such as projects, elements or views, returns them a page at a time, in this shape:
{ "object": "list", "data": [ … ], "hasMore": true, "nextCursor": "eyJ2IjoxLCJsIjoi…"}To read a whole list, ask again with cursor set to nextCursor until hasMore is false:
import os, requests
def read_all(path): items, cursor = [], None while True: response = requests.get( f"https://api.farkitect.com{path}", params={"limit": 200, **({"cursor": cursor} if cursor else {})}, headers={"Authorization": f"Bearer {os.environ['FARKITECT_API_KEY']}"}, ) response.raise_for_status() page = response.json() items += page["data"] if not page["hasMore"]: return items cursor = page["nextCursor"]Three rules:
- Never assume a page is full.
limit(1 to 200, default 50) is the most a page holds. A page can hold fewer, even none, while more follow: Farkitect stops a page early when reading it would take too long, such as types with many property types. OnlyhasMoresays whether there’s more. - Pass
nextCursorback exactly as it came, to the same list. A cursor that’s been changed, or taken to another list, gets 400invalid_cursor. - Read pages one after another. A key may have only a few requests running at once (Rate limits), and pages depend on each other anyway.
Lists aren’t one snapshot: a change made while you page through can appear or not. For a consistent read, note the time before you start and compare updatedAt afterwards.
Filters
Section titled “Filters”Many lists take filters, such as type, packageId or updatedSince. Filters combine, and each id must be from the project: an id from elsewhere, or of the wrong kind, gets 404 not_found naming the filter, so a typing slip isn’t mistaken for “nothing matches”. A cursor works only with the filters it came from.