Core Concepts
Pagination
Cursor-based pagination for list endpoints in the Cresora API.
Cresora list endpoints use cursor-based pagination. This is more reliable than offset pagination for large, frequently-updated datasets — you'll never miss records or see duplicates when iterating.
Request
GET https://api.cresoracommerce.com/v1/payments?limit=25&after=pay_xxxxxxxxxx
Authorization: Bearer csk_test_xxxxxxxxxxxx| Parameter | Default | Description |
|---|---|---|
limit | 25 | Number of results per page. Max 100. |
after | — | Cursor: return records after this ID (exclusive). |
before | — | Cursor: return records before this ID (exclusive). Used for reverse pagination. |
Response shape
{
"data": [
{ "id": "pay_aaa", "amount": 5000, ... },
{ "id": "pay_bbb", "amount": 10000, ... }
],
"has_more": true,
"next_cursor": "pay_bbb"
}| Field | Description |
|---|---|
data | Array of objects for this page |
has_more | true if more records exist after the last item on this page |
next_cursor | Pass as after= to get the next page. null when has_more is false. |
Iterating all records
async function fetchAll(endpoint) {
const results = [];
let cursor = null;
do {
const url = new URL(`https://api.cresoracommerce.com${endpoint}`);
url.searchParams.set("limit", "100");
if (cursor) url.searchParams.set("after", cursor);
const res = await fetch(url, {
headers: { Authorization: "Bearer csk_test_xxxxxxxxxxxx" }
});
const page = await res.json();
results.push(...page.data);
cursor = page.has_more ? page.next_cursor : null;
} while (cursor);
return results;
}💡Tip
Use limit=100 (the maximum) when iterating large datasets to minimize the number of requests and reduce your chance of hitting rate limits.