TrackMe API Docs
Getting started

Pagination & Cursors

How to page through TrackMe list endpoints — opaque cursor pagination by default, the chat before variant, and admin-only offset pages.

Almost every list endpoint in the TrackMe API is cursor-paginated. You ask for a page, the server hands back the page plus an opaque meta.pagination.nextCursor, and you feed that cursor straight back to fetch the next page. You never construct, decode, or guess a cursor — it is a base64url blob that encodes the server's keyset position, and the only valid thing to do with it is echo it back verbatim.

Cursor pagination is not page-number pagination. Do not increment cursors, cache them across refreshes, build ?page=2 URLs for cursor endpoints, or stop solely on an empty items array. Read the end-to-end sequence below, then the per-style detail.

All list endpoints use the standard envelope. Pagination state lives under meta.pagination, never inside data:

{
  "data": { "items": [ /* … */ ] },
  "meta": { "requestId": "req_01...", "pagination": { "nextCursor": "eyJ...", "hasMore": true, "limit": 20 } }
}

There are three pagination styles in the API, and you must not assume which one a given endpoint uses:

  1. Cursor (the default — almost all mobile lists): ?cursor= + ?limit=, returns meta.pagination.nextCursor.
  2. before cursor (chat message history only): ?before= + ?limit=, returns meta.pagination.nextCursor.
  3. Offset (admin JSON API only — /api/v1/admin/*): ?page= + ?limit=, returns meta.pagination.{page,perPage,total,lastPage}.

A handful of small lists are single-page and have no pagination object at all — see Single-page lists. Always branch on the shape of meta.pagination, not on the endpoint name.

End-to-end sequence (cursor pagination)

This is the loop for the common case — GET /api/v1/trucks/search, GET /api/v1/community/posts, and friends.

Step 1 — First request: send a limit, no cursor

Omit cursor entirely on the first page. Send limit (or accept the server default).

GET /api/v1/community/posts?limit=20 HTTP/1.1
Host: api.trackme.example
Authorization: Bearer oat_abc123...
Accept-Language: en

Step 2 — Read the page and the next cursor

The page is data.items. The cursor for the next page is meta.pagination.nextCursor.

{
  "data": {
    "items": [
      { "id": "post_01HX...", "body": "New location today!", "createdAt": "2026-06-21T08:30:00.000Z" }
    ]
  },
  "meta": {
    "requestId": "req_01HX...",
    "pagination": { "nextCursor": "eyJjcmVhdGVkQXQiOiIyMDI2...", "hasMore": true, "limit": 20 }
  }
}

Step 3 — Next request: echo nextCursor back as cursor

Pass the exact string from meta.pagination.nextCursor as the ?cursor= query param. Keep limit the same.

GET /api/v1/community/posts?limit=20&cursor=eyJjcmVhdGVkQXQiOiIyMDI2... HTTP/1.1
Host: api.trackme.example
Authorization: Bearer oat_abc123...

Step 4 — Stop when nextCursor is null

When the server has no more rows, meta.pagination.nextCursor is null (and hasMore is false). That — not an empty items array — is your terminal condition.

{
  "data": { "items": [ /* last few rows */ ] },
  "meta": { "requestId": "req_01HX...", "pagination": { "nextCursor": null, "hasMore": false, "limit": 20 } }
}

Cursor pagination — the details

This is the default style, backed by a shared keyset helper, so the contract is identical across endpoints that use it.

Request parameters

ParamTypeDefaultNotes
cursorstring (opaque)noneOmit on the first page. On later pages, the value of the previous response's meta.pagination.nextCursor, echoed verbatim.
limitintegerendpoint-specific (commonly 20)Page size. Each endpoint clamps to its own max (e.g. community posts cap at 50).

Response meta.pagination shape

FieldTypeMeaning
nextCursorstring | nullPass back as ?cursor= to get the next page. null means you've reached the end.
hasMorebooleantrue if another page exists. Equivalent to nextCursor !== null.
limitintegerThe page size that was applied (the server's clamped value, which may be lower than what you asked for).

What a cursor actually is (and why you must not parse it)

A cursor is a base64url-encoded JSON object describing the server's position in a deterministic ORDER BY — for a plain chronological list that's { id }; for ranked lists (geo + featured + rating) it carries the extra ranking fields. The encoding is an implementation detail and can change without notice. Treat it as an opaque token: store it if you must, echo it back, but never decode it, mutate it, or hand-craft one. A malformed cursor is rejected.

A cursor is not a page number. Do not do arithmetic on it, do not persist it as a durable bookmark across app restarts (the underlying rows may have shifted), and do not try to "jump" to page N. Cursor pagination is forward-only sequential paging. If you need random page access or a total count, that capability does not exist on these endpoints — only the admin offset endpoints expose total/lastPage.

Endpoints using cursor pagination

These return meta.pagination.{ nextCursor, hasMore, limit }:

  • GET /api/v1/trucks/search — public truck discovery (cursor + limit, default 20). The cursor encodes ranking when a geo query is in play.
  • GET /api/v1/community/posts — community feed (cursor + limit, 1–50, default 20).
  • GET /api/v1/community/posts/:id/replies — replies on a post (cursor + limit, 1–50, default 20).

See Discovery & search and Community for the per-feature field details.

The before variant — chat message history

Chat message history pages backwards in time and uses before instead of cursor. The intent is "give me the messages older than the one I currently have at the top of the list."

GET /api/v1/chats/conv_01HX.../messages?limit=50&before=msg_01HX... HTTP/1.1
Host: api.trackme.example
Authorization: Bearer oat_abc123...
{
  "data": { "items": [ /* messages, newest first */ ] },
  "meta": { "requestId": "req_01HX...", "pagination": { "nextCursor": "msg_01HW...", "limit": 50 } }
}
ParamTypeDefaultNotes
beforestringnoneA message id. Returns messages older than it. Omit for the most recent page.
limitinteger501–100.

Differences from the default style to watch for:

  • The request param is before, not cursor.
  • The response meta.pagination has nextCursor and limit only — there is no hasMore field here. Stop when nextCursor is null.
  • To page further back, pass the returned nextCursor as the next before.

Full chat flow: Chat & realtime.

Offset pagination — admin JSON API only

The admin endpoints under /api/v1/admin/* use classic offset paging because operators frequently scan deep into heavy tables and need a total count and the ability to jump to a page. No mobile-app endpoint uses this style — if you are building the customer or owner app, you will never hit it.

GET /api/v1/admin/orders?page=2&limit=50&status=completed HTTP/1.1
Host: api.trackme.example
Authorization: Bearer oat_admin...
{
  "data": { "items": [ /* … */ ] },
  "meta": {
    "requestId": "req_01HX...",
    "pagination": { "page": 2, "perPage": 50, "total": 1840, "lastPage": 37 }
  }
}
ParamTypeDefaultNotes
pageinteger11-based page index.
limitinteger50Page size, max 100.
Response fieldTypeMeaning
pageintegerThe page returned.
perPageintegerThe applied page size.
totalintegerTotal matching rows across all pages.
lastPageintegerThe highest valid page value.

Increment page until page === lastPage. Note these field names (perPage, lastPage) differ from the cursor style — do not write one parser and point it at both.

Single-page lists

A few lists are intentionally capped to a single response and carry no pagination object at all. Do not loop on these — there is no nextCursor to follow. Read every row from data.items once.

EndpointCapNotes
GET /api/v1/notificationslimit (default 50)Returns one page; meta carries unreadCount, no pagination. Backstops the SSE/FCM push feed on app open / pull-to-refresh.
GET /api/v1/chatsn/aThe conversation inbox returns all of the caller's conversations in one shot — no cursor, no pagination. (Message history within a chat uses the before variant above.)
GET /api/v1/jobslimit (default 20)Public job discovery returns a single page of live listings; no pagination object.

The signal for "is this list paginated?" is the presence of meta.pagination. If it is absent, you have the whole list. If it is present, page until the style's terminal condition (nextCursor === null for cursor/before, page === lastPage for offset).

State / transitions reference

A pagination loop is a tiny state machine. Drive it off the response, never off a counter you maintain.

StateMeaningHow you got hereWhat's allowed next
initialNo request sent yetApp opened the list / pull-to-refreshSend page 1: omit cursor/before/page (or page=1), send limit.
has-nextA page returned with a non-null cursor (or page < lastPage)Server had more rows than limitEcho nextCursor → cursor/before, or page + 1. Append items to the list.
exhaustedLast page returnednextCursor === null (cursor/before) or page === lastPage (offset)Stop. Re-enter initial only on a fresh refresh.
single-pageEndpoint has no pagination objectCalled a single-page list (notifications, chats inbox, jobs)Render all items; do not loop.

Transitions:

  • initial → has-next — first page came back with hasMore: true / nextCursor set / page < lastPage.
  • initial → exhausted — first page already had nextCursor: null / page === lastPage (the list fit in one page).
  • has-next → has-next — keep paging; each response either keeps the cursor flowing or flips you to exhausted.
  • has-next → exhausted — the server returned nextCursor: null (or you reached lastPage).
  • * → initial — user pull-to-refreshes; discard the old cursor and start clean from page 1.

Implementation Notes

  • Stopping on empty items. A cursor page can occasionally come back short while nextCursor is still non-null. Stop on nextCursor === null / hasMore === false, never on items.length.
  • Mutating or constructing a cursor. Cursors are opaque base64url tokens. Hand-rolling ?page=2 against a cursor endpoint, or appending to the cursor string, produces an Invalid cursor error or wrong results.
  • Re-using a stale cursor after refresh. On pull-to-refresh, drop the cursor and re-request page 1. Cursors point at row positions that may have shifted.
  • Sharing one parser across styles. Cursor → { nextCursor, hasMore, limit }. Chat → { nextCursor, limit }. Offset → { page, perPage, total, lastPage }. Branch on which keys are present.
  • Assuming a total. Cursor and before endpoints deliberately omit a total count — there is no "X of Y" without paging to the end. Only the admin offset endpoints expose total/lastPage.

See the API reference for the exact query parameters and response schema of each list endpoint.

On this page