Skip to main content

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:

ParameterDescription
pageThe page number, zero-based (the first page is 0).
sizeThe items per page (defaults to 10, maximum 100).
sortOptional 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
}
}
FieldDescription
contentThe array of items for this page.
totalSizeThe total number of items across all pages.
totalPagesThe total number of pages at the current size.
pageablePaging 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​