stable.se

API-Tokens und Webhooks gehören heute zu keinem unserer Pläne. Schreiben Sie uns, bevor Sie auf der API aufbauen.

Die Entwicklerdokumentation ist derzeit nur auf Englisch verfügbar.

Pagination

Navigate large datasets efficiently with cursor-based and offset pagination.

2 min read

Pagination is endpoint-specific

List endpoints use cursor pagination, offset pagination, or both. Some return every item at once. Check each endpoint in the API reference for the parameters it accepts and the fields it returns.

Cursor pagination

Horse search (GET /v1/horses/search) uses cursor pagination by default:

curl "https://api.stable.se/v1/horses/search?limit=20" \
  -H "Authorization: Bearer $STABLE_TOKEN"

The page holds the items, a next_cursor and has_more:

{
  "items": [
    { "public_id": "hrs_example", "name": "Starlight" }
  ],
  "next_cursor": "opaque-cursor-from-server",
  "has_more": true
}

Depending on the endpoint, these fields can sit inside a data envelope (see Getting Started). Request the next page with the returned next_cursor, keeping the same filters and sort:

curl --get "https://api.stable.se/v1/horses/search" \
  --data-urlencode "cursor=$NEXT_CURSOR" \
  --data-urlencode "limit=20" \
  -H "Authorization: Bearer $STABLE_TOKEN"

For horse search, limit defaults to 50 and is clamped to 1–100.

Offset pagination

Endpoints that support offsets take offset and limit and return items with a total. Horse search switches to offset pagination when you send offset, or pagination_mode=offset:

curl "https://api.stable.se/v1/horses/search?pagination_mode=offset&offset=40&limit=20" \
  -H "Authorization: Bearer $STABLE_TOKEN"

total counts the items you can see. What it covers can differ between endpoints, so read it per endpoint.

Cursor rules

  • Treat cursors as opaque values. Do not construct or parse them.
  • Keep the endpoint, filters, scope and sort the same between pages; start again from the first page after changing them.
  • Stop when has_more is false. A page can hold fewer items than limit even when more follow.
  • Do not store cursors for later. Changes to the data or to your access can invalidate them.