Pagination

Every list endpoint in the API — public and dashboard alike — uses the same cursor-based pagination. Learn it once.

Request

Two optional query parameters: cursor (the id of the last item you saw) and limit (1–100, default 20).

Response

json
{
  "data": [ /* up to `limit` items */ ],
  "nextCursor": "doc_01h..." // or null when this was the last page
}

nextCursor is only present when the page was completely full — a short page always means there's nothing left to fetch, so you never have to make one extra request just to find that out.

Paging through everything

javascript
let cursor;
const all = [];

do {
  const url = new URL("https://api.nexus.chaitanya-bajpai.xyz/v1/knowledge-bases/kb_123/documents");
  url.searchParams.set("limit", "100");
  if (cursor) url.searchParams.set("cursor", cursor);

  const res = await fetch(url, { headers: { Authorization: "Bearer rk_live_..." } });
  const page = await res.json();
  all.push(...page.data);
  cursor = page.nextCursor;
} while (cursor);