Pagination

Read long lists page by page with limit and cursor.

After this page you will be able to read every page of a list and avoid the cursor mistakes that end in a 422.

Prerequisites: an API key with the reviews:read permission (see Authentication) and Node.js 20 or later for the example at the end.

How paging works

GET /api/2026-07/reviews is cursor-paginated. You ask for a page size with limit (an integer from 1 to 100, default 25). The answer carries the page size and a cursor for the next page in meta.pagination:

"meta": {
  "timestamp": "2026-07-14T09:30:12.481Z",
  "pagination": { "limit": 25, "nextCursor": "WyIyMDI2LTA2LTEwIiwiNDgxNTE2MjM0MjoxMjAwMzExIl0" }
}

To get the next page, send nextCursor back as the cursor query parameter. On the last page nextCursor is null: stop there. A full last page still ends with null, so you never need an extra empty request.

const next = page.meta.pagination.nextCursor;
const url = next ? `${BASE_URL}/api/2026-07/reviews?limit=25&cursor=${encodeURIComponent(next)}` : null;
ParameterMeaning
limitPage size, 1 to 100, default 25. Values outside the range are a 422.
cursorThe nextCursor of the previous page. Omit it for the first page.

GET /api/2026-07/reviews/count has no paging: it returns the total for the filters in one call.

A cursor is opaque and belongs to its query

Treat a cursor as an opaque string: do not parse, build or edit it. It encodes the position after the last review of the page, in the order given by sort. That is why a cursor only works together with the query it was issued for:

  • Keep the same sort and sortDirection on every page. A cursor used with another sort is a 422 with code VALIDATION_ERROR and the error cursor: cursor does not belong to this sort.
  • Keep the same filters (status, rating, appId, customerId) on every page. Changing them in the middle of a walk gives a list that is not meaningful.
  • A cursor that is not valid at all (edited, truncated) is a 422 with cursor: cursor is not valid.
  • Do not store cursors for later. Start from the first page when you need fresh data.

Reviews can be added or deleted while you page. You may then see a review created after you started, or miss one that was deleted; the paging itself does not repeat a review.

Next steps

  • Reviews: the filters and sort options to combine with paging.
  • Errors: how to handle a 422 or a 503 in the middle of a walk.

Example

A complete program that reads every published review of one app, page by page, with the largest page size, and retries temporary failures with exponential backoff. Run it with NORTLY_API_KEY=<your key> APP_ID=4815162342 npx tsx all-reviews.ts.

const BASE_URL = "https://api.nortly.app";
const API_KEY = process.env.NORTLY_API_KEY;
const APP_ID = process.env.APP_ID;

if (!API_KEY) {
  throw new Error("Set NORTLY_API_KEY to an API key with the reviews:read permission");
}

type Review = { id: string; rating: number; text: string; createdAt: string };

type ListResponse = {
  success: true;
  data: Review[];
  meta: { timestamp: string; pagination: { limit: number; nextCursor: string | null } };
};

type ErrorResponse = { success: false; message: string; code: string; errors?: string[] };

const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));

async function fetchPage(params: URLSearchParams): Promise<ListResponse> {
  for (let attempt = 0; ; attempt++) {
    const response = await fetch(`${BASE_URL}/api/2026-07/reviews?${params}`, {
      headers: { Authorization: `Bearer ${API_KEY}` },
    });

    if (response.ok) return (await response.json()) as ListResponse;
    if (response.status === 401) throw new Error("401: the API key is missing or invalid");

    const error = (await response.json()) as ErrorResponse;
    if (response.status === 503 && attempt < 4) {
      await sleep(1000 * 2 ** attempt); // 1 s, 2 s, 4 s, 8 s
      continue;
    }
    throw new Error(`${response.status} ${error.code}: ${error.message} ${(error.errors ?? []).join("; ")}`);
  }
}

async function readAllReviews(): Promise<Review[]> {
  // The sort, the direction and the filters stay the same on every page.
  const params = new URLSearchParams({ limit: "100", sort: "createdAt", sortDirection: "desc" });
  if (APP_ID) params.set("appId", APP_ID);

  const reviews: Review[] = [];
  let cursor: string | null = null;
  do {
    if (cursor) params.set("cursor", cursor);
    const page = await fetchPage(params);
    reviews.push(...page.data);
    cursor = page.meta.pagination.nextCursor;
    console.log(`page read: ${page.data.length} review(s), more: ${cursor !== null}`);
  } while (cursor);

  return reviews;
}

try {
  const reviews = await readAllReviews();
  console.log(`${reviews.length} review(s) in total`);
} catch (error) {
  console.error(error instanceof Error ? error.message : error);
  process.exitCode = 1;
}

Expected output (values depend on your workspace):

page read: 100 review(s), more: true
page read: 100 review(s), more: true
page read: 37 review(s), more: false
237 review(s) in total

Did this page help you?