Pagination
Browse resource lists with the per_page and page parameters, and read pagination metadata.
Endpoints that return a list (payments, transfers, customers) are paginated. Each
response contains an items array and a meta object describing the current page.
GET
https://api.wajub.com/paymentsParameters
per_pageintegeroptionaldefault : 25Number of items per page (1–100).
pageintegeroptionaldefault : 1Page number to retrieve (offset pagination).
cursorstringoptionalOpaque cursor from a previous response, for cursor-based pagination on large datasets. Mutually exclusive with `page`.
statusstringoptionalOptional filter, e.g. status=succeeded.
date_from / date_todateoptionalBounds the period on created_at (YYYY-MM-DD).
GET
https://api.wajub.com/payments?per_page=2&page=1&status=succeededRequest
curl "https://api.wajub.com/payments?per_page=2&page=1&status=succeeded" \
-H "Authorization: pk_test.8f2b91c4d7e6a0f3"Response
{
"code": 200,
"status": "OK",
"message": "Payments retrieved",
"items": [
{ "id": "trx_01JXXXXXXXXXXXXX", "status": "succeeded", "amount": 5000 },
{ "id": "trx_01JYYYYYYYYYYYYY", "status": "succeeded", "amount": 12000 }
],
"meta": {
"current_page": 1,
"last_page": 69,
"per_page": 2,
"total": 137
}
}Iterating over all pages (offset)
Browsing pages
let page = 1;
let all = [];
while (true) {
const res = await fetch(`https://api.wajub.com/payments?per_page=100&page=${page}`, {
headers: { Authorization: process.env.WAJUB_SECRET_KEY },
});
const { items, meta } = await res.json();
all.push(...items);
if (page >= meta.last_page) break;
page++;
}Cursor pagination
For large datasets, pass cursor instead of page. The response meta then returns
next_cursor / prev_cursor / has_more rather than current_page / last_page / total:
{
"code": 200,
"status": "OK",
"message": "Payments retrieved",
"items": [ /* ... */ ],
"meta": {
"per_page": 25,
"next_cursor": "eyJpZCI6InRyeF8wMUpYWFgi...",
"prev_cursor": null,
"has_more": true
}
}Pass the next_cursor value back as cursor on the following request; stop once has_more
is false.
Prefer webhooks over polling
To react to a status change, subscribe to Webhooks rather than paginating in a loop. Pagination is for exports and history screens.