Skip to content

Pagination

All API responses use a standard JSON envelope. List endpoints include pagination metadata to help you iterate through large datasets.


Response Envelope

Every response wraps its payload in a data field:

{
"data": { ... }
}

List endpoints also include a pagination object:

{
"data": [ ... ],
"pagination": {
"page": 1,
"limit": 50,
"total": 342,
"has_next": true,
"next_cursor": "bzo1MA"
}
}

Pagination Fields

FieldTypeDescription
pageintegerCurrent page number (1-indexed)
limitintegerNumber of items per page
totalintegerTotal number of items across all pages
has_nextbooleantrue if more pages are available
next_cursorstring | nullOpaque cursor for the next page; null on the last page. Pass it back as cursor.

Query Parameters

All list endpoints accept these pagination parameters:

ParameterTypeDefaultRangeDescription
pageinteger11+Page number to retrieve
limitinteger501-200Number of items per page
cursorstringOpaque cursor from a prior response’s next_cursor. Takes precedence over page.

You can paginate two ways: by page number (page) or by opaque cursor (cursor). They share the same limit. When you send a cursor, the page parameter is ignored.


Iterating Through Pages

Use has_next to determine when to stop paginating.

Terminal window
# Fetch page 1
curl "https://be.graph8.com/api/v1/contacts?page=1&limit=100" \
-H "Authorization: Bearer $API_KEY"
# If has_next is true, fetch page 2
curl "https://be.graph8.com/api/v1/contacts?page=2&limit=100" \
-H "Authorization: Bearer $API_KEY"

Cursor Pagination

For forward iteration you can follow next_cursor instead of incrementing page. The cursor is an opaque token — don’t parse or construct it; just pass the last response’s next_cursor back as the cursor parameter. When next_cursor is null, you’ve reached the end.

This is the Stripe starting_after / Twilio PageToken equivalent, and is the recommended pattern for scripts that walk an entire list.

Terminal window
# First page — no cursor
curl "https://be.graph8.com/api/v1/usage/transactions?limit=100" \
-H "Authorization: Bearer $API_KEY"
# => { "data": [...], "pagination": { "next_cursor": "bzoxMDA", ... } }
# Next page — pass the previous next_cursor
curl "https://be.graph8.com/api/v1/usage/transactions?limit=100&cursor=bzoxMDA" \
-H "Authorization: Bearer $API_KEY"

A malformed or foreign cursor returns 400 with { "type": "bad_request", ... }.


Best Practices

  • Prefer cursor for walking an entire list — follow next_cursor until it’s null. Use page only when you need to jump to a specific page number.
  • Use the maximum limit (200) when exporting large datasets to minimize requests.
  • Check has_next (or a null next_cursor) instead of computing from page * limit < total — this avoids off-by-one errors.
  • Respect rate limits — add a short delay between pages if fetching many pages. See Rate Limits.
  • Don’t assume order — results are returned in the default order for each resource. If you need a specific order, sort client-side.