Paging
Collections that page carry a cursor. Follow it until the API says there are no more:
{
"data": [ ... ],
"meta": { "has_more": true, "next_cursor": "eyJpZCI6InByb3BfMWI3N2UwYTRmMiJ9" }
}The only correct stopping condition
Stop when has_more is false. Not when a page comes back shorter than the
limit you asked for, which is the mistake almost everybody makes first: a full
page can still be the last one, and a short page can still carry a cursor.
Why a cursor rather than a page number
Cursors are stable across inserts. Paging by offset over a catalogue that is being written to will skip records and show you others twice, and it will do it quietly.
Let the client do it
Every Skautik client has an iterator that follows the cursor, so this is one line rather than a loop:
for await (const property of skautik.properties.listAll({ city: "Berlin" })) {
console.log(property.title);
}for property in skautik.properties.list_all(city="Berlin"):
print(property.title)for property, err := range skautik.AllProperties(
client.Properties.ListProperties(ctx).City("Berlin"),
) {
if err != nil {
return err
}
fmt.Println(property.Title)
}They also stop if the cursor ever fails to move, so a fault at our end cannot become a loop at yours that never finishes.