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:
{
"data": [...],
"pagination": {
"next_cursor": "dGhpcyBpcyBhIGN1cnNvcg",
"has_more": true
}
}
| Field | Description |
|---|---|
next_cursor | Opaque cursor string to pass as the cursor query parameter for the next page. null when there are no more results. |
has_more | true if there are more results beyond this page. |
Fetching the next page
Pass the next_cursor value as the cursor query parameter:
# 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:
| Parameter | Default | Min | Max |
|---|---|---|---|
limit | 50 | 1 | 100 |
Iterating through all results
To fetch all records, loop until has_more is false:
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:
| Endpoint | Description |
|---|---|
GET /api/v1/affiliates | List affiliates |
GET /api/v1/commissions | List commissions |
GET /api/v1/payouts | List payouts |