Pagination
List endpoints return a pagination envelope alongside the data:
{
"data": [...],
"pagination": {
"page": 1,
"per_page": 20,
"total": 142,
"total_pages": 8
}
}
Query parameters
| Parameter | Type | Default | Max |
|---|---|---|---|
page | integer | 1 | none |
per_page | integer | 20 | 100 |
A page below 1 falls back to 1. A per_page outside 1–100 falls back to the default of 20 (it is not clamped to 100), so always send a value within range.
Iterating
async function* iterateAll(path, token) {
let page = 1;
while (true) {
const res = await fetch(`https://perks.founderpass.com${path}?page=${page}&per_page=100`, {
headers: { Authorization: `Bearer ${token}` },
}).then((r) => r.json());
yield* res.data;
if (page >= res.pagination.total_pages) break;
page++;
}
}