Skip to content

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.

GEThttps://api.wajub.com/payments

Parameters

per_pageintegeroptionaldefault : 25
Number of items per page (1–100).
pageintegeroptionaldefault : 1
Page number to retrieve (offset pagination).
cursorstringoptional
Opaque cursor from a previous response, for cursor-based pagination on large datasets. Mutually exclusive with `page`.
statusstringoptional
Optional filter, e.g. status=succeeded.
date_from / date_todateoptional
Bounds the period on created_at (YYYY-MM-DD).
GEThttps://api.wajub.com/payments?per_page=2&page=1&status=succeeded
curl "https://api.wajub.com/payments?per_page=2&page=1&status=succeeded" \
-H "Authorization: pk_test.8f2b91c4d7e6a0f3"
Response · 200 OK
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)

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:

Cursor pagination response
{
"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.