Pagination#
All top-level API resources have support for bulk fetches via "list" API methods. These list API methods share a common structure, accepting at least these three parameters: limit, starting_after, and ending_before.
Cursor-Based Pagination#
CasaPay uses cursor-based pagination via the starting_after and ending_before parameters. Both parameters take an existing object ID value and return objects in reverse chronological order.
Parameters#
| Parameter | Type | Description |
|---|---|---|
limit | integer | Number of objects to return (1–100, default 10) |
starting_after | string | Cursor for forward pagination. The ID of the last object in the previous page. |
ending_before | string | Cursor for backward pagination. The ID of the first object in the previous page. |
Response Format#
{
"object": "list",
"data": [
{ "id": "cus_123", "object": "customer", "..." : "..." },
{ "id": "cus_124", "object": "customer", "..." : "..." }
],
"has_more": true,
"url": "/v1/customers"
}Paginating Forward#
To retrieve the next page, pass the ID of the last object as starting_after:
curl https://api.casapay.com/v1/customers?limit=10&starting_after=cus_124 \
-H "Authorization: Bearer sk_test_4eC39HqLyjWDarjtT1zdp7dc"const customers = await casapay.customers.list({
limit: 10,
starting_after: 'cus_124',
});Auto-Pagination#
Our client libraries support auto-pagination to iterate through all results:
for await (const customer of casapay.customers.list({ limit: 100 })) {
console.log(customer.id);
}for customer in casapay.Customer.list(limit=100).auto_paging_iter():
print(customer.id)