API · v1 · stable
CODEMETA OSDeveloper Center
EN
Open console
Concept

Pagination

Reading time · 7 minUpdated · 19 October 2026

Every list endpoint (GET /api/v1/<resource>) returns a page, never the complete dataset. The page is in data, the paging information in meta.

{
  "data": [ … ],
  "meta": {
    "nextCursor": "0192f2c0-8d1c-7a3b-9e4f-d3e7f1a2b5c8",
    "hasMore": true,
    "limit": 50
  }
}

There are two paging methods: offset (the standard way) and cursor (for large traversals). You control both via query parameters.

Query parameters

Parameter Type Default Meaning
limit number 50 Rows per page. Hard-capped at 200 (see note below).
offset number 0 Rows to skip. Offset paging.
cursor string – UUID of the last row read. Cursor paging.
sort string – Field to sort by.
order string asc asc or desc. Only effective together with sort.
withTotal boolean false If true, meta additionally contains total (exact hit count).

Offset paging

The standard way. You increase offset by limit until hasMore is false.

curl "https://os.codemeta.de/api/v1/tickets?limit=100&offset=200" \
  -H "X-Tenant-Id: $TENANT" \
  -b cookies.txt

Offset paging works with any sort order and is the right choice for UI pages, jumps to a specific page and traversals of up to a few thousand rows. For very deep traversals, offset gets slower with increasing depth — cursor paging is the better choice there.

Cursor paging

Instead of skipping, you start from the last record read. The cursor is the nextCursor value from the previous response.

CURSOR="0192f2c0-8d1c-7a3b-9e4f-d3e7f1a2b5c8"   # meta.nextCursor of the previous page

curl "https://os.codemeta.de/api/v1/tickets?limit=100&sort=_id&order=asc&cursor=$CURSOR" \
  -H "X-Tenant-Id: $TENANT" \
  -b cookies.txt

An invalid cursor (not in UUID format) is rejected with 400, not silently ignored.

The meta object

Field Type Always present? Meaning
nextCursor string | null yes ID of the last row of this page, or null on the last page.
hasMore boolean yes Whether at least one more row exists.
limit number yes The limit actually applied — after the 200 cap.
total number no Exact hit count. Only with ?withTotal=true.

hasMore is determined by reading one extra element (limit + 1), not by a count query. That is why total is not included by default: an exact count costs 50–200 ms per request on large data sets, which most clients never read. If you display a hit count (“1,284 results”), request it with ?withTotal=true.

Sorting and stability

Without sort, results are sorted by createdAt descending (newest first). With sort, order applies, which defaults to asc.

Every sort order gets _id appended server-side as a tiebreaker. This is mandatory for offset paging: with multiple rows sharing an identical sort value — for example hundreds of records from the same import with the same createdAt — the database does not guarantee a stable order between two separate page requests without a unique tiebreaker. Rows would otherwise fall between the page boundaries and never show up.

Full traversal

Read all tickets of a tenant, by cursor:

NEXT=""
while : ; do
  RES=$(curl -s "https://os.codemeta.de/api/v1/tickets?limit=200&sort=_id&order=asc${NEXT:+&cursor=$NEXT}" \
    -H "X-Tenant-Id: $TENANT" -b cookies.txt)

  echo "$RES" | jq -c '.data[]' >> tickets.ndjson

  [ "$(echo "$RES" | jq -r '.meta.hasMore')" = "true" ] || break
  NEXT=$(echo "$RES" | jq -r '.meta.nextCursor')
done

Deviating response shape on some endpoints

The generic entity lists and the timeline route respond with meta. Some older, non-generic endpoints — users, invitations, sessions, notifications, and the security and vault audit logs — return this instead:

{
  "data": [ … ],
  "pagination": {
    "cursor": "0192f2c0-…",
    "hasMore": true
  }
}

In substance, pagination.cursor is the same as meta.nextCursor. Read defensively (meta ?? pagination, nextCursor ?? cursor) if your client talks to both endpoint families. Unifying on meta is planned; removing pagination would be announced beforehand in the changelog.

Limits

  • limit is at most 200 per page.
  • Every list query has a server-side timeout of 15 seconds (all limits: Limits). A timeout is almost always a filter that hits no index — narrow the scope instead of raising the limit.
  • Polling lists is the wrong way to keep data up to date. Use webhooks and use listing only for the initial population.

Search