Pagination

How to paginate through large result sets using cursor-based pagination.

Overview

All list endpoints in the Anderro API use cursor-based pagination. This approach provides consistent results even when new records are added between requests, making it ideal for real-time data.

How it works

Each paginated response includes a pagination object:

json
{
  "data": [...],
  "pagination": {
    "next_cursor": "dGhpcyBpcyBhIGN1cnNvcg",
    "has_more": true
  }
}
FieldDescription
next_cursorOpaque cursor string to pass as the cursor query parameter for the next page. null when there are no more results.
has_moretrue if there are more results beyond this page.

Fetching the next page

Pass the next_cursor value as the cursor query parameter:

bash
# First page
curl https://anderro.com/api/v1/affiliates?limit=20 \
  -H "x-api-key: sk_your_secret_key"

# Next page (using cursor from previous response)
curl "https://anderro.com/api/v1/affiliates?limit=20&cursor=dGhpcyBpcyBhIGN1cnNvcg" \
  -H "x-api-key: sk_your_secret_key"

Page size

Use the limit parameter to control the number of results per page:

ParameterDefaultMinMax
limit501100

Iterating through all results

To fetch all records, loop until has_more is false:

javascript
async function fetchAllAffiliates(apiKey) {
  const affiliates = [];
  let cursor = null;

  do {
    const url = new URL("https://anderro.com/api/v1/affiliates");
    url.searchParams.set("limit", "100");
    if (cursor) url.searchParams.set("cursor", cursor);

    const res = await fetch(url, {
      headers: { "x-api-key": apiKey },
    });
    const json = await res.json();

    affiliates.push(...json.data);
    cursor = json.pagination.next_cursor;
  } while (cursor);

  return affiliates;
}

Cursor stability

Cursors are stable across requests - adding or removing records won't cause items to be skipped or duplicated. However, cursors are opaque and may change format between API versions. Do not parse or construct cursors manually.

Paginated endpoints

The following endpoints support cursor-based pagination:

EndpointDescription
GET /api/v1/affiliatesList affiliates
GET /api/v1/commissionsList commissions
GET /api/v1/payoutsList payouts