Pagination
List endpoints return objects newest first, a page at a time, with cursor pagination.
Query parameters (every list endpoint)
| Field | Type | Description |
|---|---|---|
limit |
integer | How many objects to return, 1–100. Default 20. |
starting_after |
string | An object id. Returns the objects after it in the list (older ones): the next page. |
ending_before |
string | An object id. Returns the objects before it in the list (newer ones): the previous page. |
The list object
{
"object": "list",
"data": [ { "id": "pay_…", "object": "payment", … }, … ],
"has_more": true
}
has_more is true when there are more objects beyond this page.
Walking through every page
let startingAfter;
do {
const url = new URL("https://api.klinkpay.net/v1/payments");
url.searchParams.set("limit", "100");
if (startingAfter) url.searchParams.set("starting_after", startingAfter);
const page = await (await fetch(url, { headers: { Authorization: `Bearer ${key}` } })).json();
for (const payment of page.data) handle(payment);
startingAfter = page.has_more ? page.data.at(-1).id : undefined;
} while (startingAfter);