Backend (Go) - Pagination API Backend (Go) - Pagination API All Go backend list endpoints return a consistent paginated response envelope. Two modes are supported: offset (page-numbered) and cursor (token-based).

Response Shape

The top-level items array always contains the page of data. The pagination object contains navigation metadata.

Offset Mode

Use for static datasets where total count is known and users may jump to arbitrary pages (e.g. audit logs, reports).

Cursor Mode

Use for frequently-updated lists where consistent ordering matters (e.g. activity feeds, inventory, transactions).

Field Reference

hasNext and hasPrev are always present in both modes — use them to enable/disable navigation controls without branching on mode.

hasNext / hasPrev Semantics

Both fields are computed server-side at response time.

Switching Modes

Send the X-Pagination-Type request header to select the mode. Defaults to offset when the header is absent.

Cursor Mode with Total Count

By default cursor responses omit totalPages and totalRecords to avoid an extra COUNT query. Pass ?include_total=true to opt in:
include_total=true triggers an additional database COUNT query on every request. Use it only when the total count is needed by the UI — for example, showing “480 records” alongside cursor navigation.

Request Parameters


Handler Usage (Go)

The pagination.Wrap function always produces { "items": ..., "pagination": ... } — handlers must not construct the envelope manually.

Limit Cap

The maximum allowed limit is 100. Requests with limit > 100 fall back to the default of 20.