Pagination
List endpoints, cursors, and auto-pagination helpers.
All list(...) methods on the SDK use offset-based pagination with
two keyword arguments:
| Argument | Type | Default | Notes |
|---|---|---|---|
limit | int | None | server | Page size. The server enforces an upper bound. |
offset | int | None | server | How many records to skip from the start. |
Most list(...) methods return a plain list of typed models —
not a paginated wrapper. The total count is not returned, so you
paginate by walking the offset until you see fewer results than the
page size.
A handful of endpoints return a paginated envelope ({ data, total, limit, offset }); those are called out below.
Treasury transactions (
client.treasury.list_transactions) are the exception — they use cursor-based pagination viacursor=/next_cursor. See the Treasury page.
Manual pagination
PAGE_SIZE = 100
offset = 0
all_customers = []
while True:
page = client.customers.list(limit=PAGE_SIZE, offset=offset)
all_customers.extend(page)
if len(page) < PAGE_SIZE:
break
offset += PAGE_SIZEIf you only need a slice, pass limit= and call it once:
recent = client.invoices.list(limit=20)Some list(...) methods accept extra filters; for example,
client.invoices.list(...) accepts status=, collection_method=,
due_date_from=, and due_date_to=. See each
resource page for the per-resource filter set.
Endpoints that return a paginated envelope
A few endpoints return { data, total, limit, offset } instead of a
bare list — typically because the server already needs total to render
a count UI. These are returned as a dict (not a model) for simplicity:
client.customers.subscriptions(customer_id, ...)—datais a list ofSubscriptionmodels,totalis the row count.client.webhooks_management.list_deliveries(...)andlist_endpoint_deliveries(...).client.treasury.list_transactions(...)— uses cursor pagination (cursor=/next_cursorin the envelope), not offset.
page = client.customers.subscriptions("cus_123", limit=25, offset=0)
print(page["total"])
for sub in page["data"]:
print(sub.id, sub.status)Auto-pagination
There is no built-in iterator helper in 0.1.x. Wrap the manual loop
in a generator if you want a Pythonic interface:
from typing import Iterator
from easylabs import Customer
def iter_all(list_fn, *, page_size: int = 100, **filters) -> Iterator[Customer]:
offset = 0
while True:
page = list_fn(limit=page_size, offset=offset, **filters)
if not page:
return
yield from page
if len(page) < page_size:
return
offset += page_size
for cust in iter_all(client.customers.list):
...