Pagination
Page through any list endpoint with limit and cursor, and fetch every result safely.
This is a published preview. Names and fields may still change before general availability; changes will be listed in the changelog.
Every endpoint that returns a list, such as GET/visits, uses cursor pagination. You ask for a page, and each page tells you whether there's another and how to get it.
Request
| Parameter | Type | Description |
|---|---|---|
limit | integer | How many items to return, from 1 to 100. Defaults to 25. |
cursor | string | The next_cursor from the previous page. Leave it out to get the first page. |
Keep every other parameter the same from page to page. A cursor belongs to the query that produced it, so don't reuse one with different filters.
Response
{
"data": [{ "id": "visit_01m4k5z4j0fxbte6sn6e8tpgza", "status": "checked_in", "…": "…" }],
"next_cursor": "b3BhcXVlLWN1cnNvcg",
"has_more": true
}Prop
Type
Cursors are opaque. Don't parse or build them, and don't store them for later: use them to page through results now.
A limit outside 1 to 100 returns validation_failed with the location query.limit.
Order
Most lists are newest first, by created_at. A few use an order that suits them better:
| List | Order |
|---|---|
| Sites | Oldest first |
| Booking types, shifts | By name |
| Attendance events | Most recent first, by occurred_at |
| Audit events | Most recent first, by occurred_at |
| Everything else | Newest first, by created_at |
Because a cursor marks a position in that order, items created while you're paging through a newest-first list land before your cursor. You won't see them twice or skip older ones, but you won't see the new ones either. To keep a copy in step, see keeping in sync.
Fetch every page
Use limit=100 when you want everything, and loop until has_more is false.
cursor=""
while :; do
args=(-sS --fail-with-body -G "https://api.agoo.ardent.africa/v1/visits"
-H "Authorization: Bearer $AGOO_API_KEY"
--data-urlencode "status=checked_in"
--data-urlencode "limit=100")
[ -n "$cursor" ] && args+=(--data-urlencode "cursor=$cursor")
page=$(curl "${args[@]}") || { echo "$page" >&2; exit 1; }
echo "$page" | jq -r '.data[] | "\(.id) \(.visitor.name)"'
[ "$(echo "$page" | jq -r '.has_more')" = "true" ] || break
cursor=$(echo "$page" | jq -r '.next_cursor')
doneA long loop makes many requests in a row. Watch the rate limit headers, and narrow the query with filters such as site_id or created_after rather than fetching everything and filtering yourself.
Keeping in sync
To keep your own copy of visits, bookings or attendance up to date:
- Backfill once by paging through the list.
- Follow changes with webhooks, which tell you about creations and every status change as they happen.
- Reconcile now and then, for example nightly, with
created_afterset to the last time you reconciled, or by reading GET/events (which keeps 30 days of events) to catch anything your endpoint missed.