Pagination & Filtering
List endpoints — GET /customers, GET /offers, GET /webhooks/endpoints, and the rest — return results one page at a time.
Requesting a page
List endpoints expect page and size as query parameters:
| Parameter | Description |
|---|---|
page | The page number, zero-based (the first page is 0). |
size | The items per page (defaults to 10, maximum 100). |
sort | Optional sort expression for the list. |
curl "https://api.loomloyalty.com/customers?page=0&size=25" \
-H "Authorization: Bearer $LOOM_API_KEY"
The page envelope
Paginated responses use the standard envelope, with the page under data:
{
"success": true,
"data": {
"content": [{ "customerId": "…" }, { "customerId": "…" }],
"pageable": {},
"totalSize": 132,
"totalPages": 6
}
}
| Field | Description |
|---|---|
content | The array of items for this page. |
totalSize | The total number of items across all pages. |
totalPages | The total number of pages at the current size. |
pageable | Paging metadata for the current request. |
Iterating every page
Request successive pages until you've walked totalPages:
async function listAllCustomers() {
const results = [];
let page = 0;
let totalPages = 1;
do {
const url = `https://api.loomloyalty.com/customers?page=${page}&size=100`;
const body = await fetch(url, {
headers: { Authorization: `Bearer ${process.env.LOOM_API_KEY}` },
}).then((r) => r.json());
results.push(...body.data.content);
totalPages = body.data.totalPages;
page += 1;
} while (page < totalPages);
return results;
}
Choose a larger size to make fewer round trips, and mind Rate Limits when walking large collections.
Next Steps
- Handle failures with Errors & Status Codes
- Browse the paginated endpoints in the API Reference