Pagination
Page through lists with limit, starting_after and has_more.
List endpoints (GET /checkout_sessions, /payments, /disputes, /payouts, /payment_links, /events, /webhook_endpoints and an endpoint's /deliveries) return objects newest first, one page at a time.
{
"data": [{ "id": "pay_01KA4Y0Z9V3T6N8Q2W5E7R1T3Y", "object": "payment", "...": "..." }],
"has_more": true
}| Parameter | |
|---|---|
limit | Page size, 1 to 100. Default 20. Out of range is 400 invalid_limit. |
starting_after | An object id from the previous page. The page starts after it. An id this key can't see is 400 invalid_cursor. |
To get the next page, pass the id of the last object in data as starting_after. Stop when has_more is false.
async function* allPayments(key) {
let startingAfter;
while (true) {
const url = new URL("https://runepay.co/api/v1/payments");
url.searchParams.set("limit", "100");
if (startingAfter) url.searchParams.set("starting_after", startingAfter);
const res = await fetch(url, { headers: { Authorization: `Bearer ${key}` } });
if (!res.ok) throw new Error(`RunePay ${res.status}`);
const page = await res.json();
yield* page.data;
if (!page.has_more || page.data.length === 0) return;
startingAfter = page.data.at(-1).id;
}
}Some lists take filters, such as status and created[gte] / created[lte] (unix seconds) on payments, payment on disputes, or active on payment links. Each endpoint's page lists its own.
Planned
A later release adds ending_before (to page backwards), object: "list" and url on every list response (payment links already return object: "list"), created[gt] / created[lt], and more filters. limit, starting_after, data and has_more keep working as they do now.