Walking Through Results
Archie's list endpoints return one page at a time. You ask for a window with limit and offset.
Each response tells you how many rows exist in total and whether another page is waiting.
Ask for a Window
A list call takes two query parameters. To read the next page, add the limit to the offset and call again.
How many rows you want. Most lists default to 20; clients.list defaults to 50.
How many rows to skip. Defaults to 0.
The Pagination Object
A REST list route, such as GET https://uk.heyarchie.com/api/v1/workstreams/workplans, carries a pagination object alongside the rows. A skill that lists, such as clients.list, puts total_count and has_more in its output instead. Read has_more to decide whether to keep going; there is no need to do the arithmetic against total yourself.
How many rows match in full, across every page.
The page size you asked for, echoed back.
How many rows were skipped to reach this page.
True when another page exists past this one.
A List Response
On a REST list route the rows sit in items, and the pagination object sits beside them.
{
"items": [ /* up to "limit" rows */ ],
"pagination": {
"total": 137,
"limit": 20,
"offset": 0,
"has_more": true
}
}Reading Every Page
Loop until has_more is false, moving the offset on by the limit each time.
def fetch_all_clients(client, page_size=50):
rows, offset = [], 0
while True:
reply = client.skills.invoke("clients.list", limit=page_size, offset=offset)
out = reply["output"]
rows.extend(out["clients"])
if not out["has_more"]:
return rows
offset += page_sizeKeep the same limit for a whole run. The offset counts rows rather than pointing at a particular one, so changing the page size partway through can skip or repeat a row near the boundary.