Pagination
Lists are newest first and page by ID. Walk them one page at a time, or let the SDKs walk every page.
On this page
Every list (payments, payment links, payouts, payout destinations, batches and refunds) is newest first and answers one page:
{ "object": "list", "data": [{ "id": "pay_…" }, { "id": "pay_…" }], "has_more": true }| Parameter | What |
|---|---|
limit | Items per page: 20 by default, at most 100. |
starting_after | An ID from the previous page: the page of older items after it. |
ending_before | An ID: the page of newer items before it. |
Plus each list's filters, such as a payment's status or order_id. has_more says whether
there is another page. Pages are by ID, so items created while you walk neither repeat nor shift
your walk: newer items appear in a new walk.
const walked: string[] = [];
let page = await nowgate.payments.list({ limit: 2 });
walked.push(...page.data.map((p) => p.id));
while (page.has_more) {
page = await nowgate.payments.list({ limit: 2, starting_after: page.data.at(-1)?.id });
walked.push(...page.data.map((p) => p.id));
}walked: List[str] = []
page = client.payments.list(limit=2)
walked += [p["id"] for p in page["data"]]
while page["has_more"]:
page = client.payments.list(limit=2, starting_after=page["data"][-1]["id"])
walked += [p["id"] for p in page["data"]]$walked = [];
$page = $nowgate->payments->list(['limit' => 2]);
foreach ($page['data'] as $payment) {
$walked[] = $payment['id'];
}
while ($page['has_more'] && $page['data'] !== []) {
$last = $page['data'][count($page['data']) - 1]['id'];
$page = $nowgate->payments->list(['limit' => 2, 'starting_after' => $last]);
foreach ($page['data'] as $payment) {
$walked[] = $payment['id'];
}
}Every page#
listAll (list_all in Python) walks every page for you, newest first, asking for 100 items at a
time unless you give a limit, and follows starting_after while has_more is true. It fetches
nothing until you iterate, stops when you do, and retries each page as any GET.
const all: string[] = [];
for await (const each of nowgate.payments.listAll()) all.push(each.id);every = [payment["id"] for payment in client.payments.list_all()]$all = [];
foreach ($nowgate->payments->listAll() as $payment) {
$all[] = $payment['id'];
}