Skip to main content

Pagination

The ION Guard API uses cursor-based pagination to navigate resource lists. This method is more efficient than offset-based pagination for large and constantly changing datasets.

How it works

Instead of numbered pages (1, 2, 3...), the API returns a cursor — an opaque token that points to a position in the dataset. You use the cursor to request the next or previous page of results.

Request parameters

ParameterDefaultDescription
limit20Number of items per page (maximum: 100)
cursorPagination token (obtained from the previous response)

limit values above 100 are automatically reduced to the ceiling of 100.

Filters by resource

Some listing endpoints accept additional filters that combine with pagination. For example, GET /api/v1/alerts (and GET /api/v1/sites/{site}/alerts) accept:

FilterDescription
typeFilters by alert type
severityFilters by severity
statusFilters by alert status

Filters are applied before pagination and automatically preserved in the links.next / links.prev URLs.

Example request

GET /api/v1/alerts?limit=10
Authorization: Bearer {token}

Response format

The response is wrapped in three blocks: data (the resources), links (navigation URLs), and meta (pagination metadata).

{
"data": [
{ "id": "9c1a...", "type": "panic", "status": "active", ... },
{ "id": "9c1b...", "type": "device-offline", "status": "acknowledged", ... }
],
"links": {
"first": null,
"last": null,
"prev": null,
"next": "/api/v1/alerts?cursor=eyJpZCI6MTAsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0&limit=10"
},
"meta": {
"path": "/api/v1/alerts",
"per_page": 10,
"next_cursor": "eyJpZCI6MTAsIl9wb2ludHNUb05leHRJdGVtcyI6dHJ1ZX0",
"prev_cursor": null
}
}
FieldDescription
dataArray of resources for the current page
links.nextFull URL for the next page (null if there are no more items)
links.prevFull URL for the previous page (null if this is the first)
links.first / links.lastAlways null in cursor-based pagination (there is no fixed first/last)
meta.pathBase path used to generate the URLs
meta.per_pageItems per page requested
meta.next_cursorCursor for the next page (null if there are no more items)
meta.prev_cursorCursor for the previous page (null if this is the first)
# First page
curl -s "https://ionguard.local/api/v1/alerts?limit=10" \
-H "Authorization: Bearer $TOKEN"

# Next page (using meta.next_cursor from the previous response)
curl -s "https://ionguard.local/api/v1/alerts?limit=10&cursor=eyJpZCI6MTAuLi4" \
-H "Authorization: Bearer $TOKEN"

End of list

When meta.next_cursor is null and links.next is null, there are no more items available.

Advantages of cursor-based pagination

  • Performance — No need to count all records (O(1) vs O(n))
  • Consistency — Insertions and deletions during navigation do not cause duplicate or skipped items
  • Scalability — Works well with millions of records