Pagination
All list endpoints return paginated responses. The SDK provides both manual pagination and auto-pagination helpers.
Response Formatโ
Every paginated response includes:
{
"data": [...],
"pagination": {
"total": 250,
"page": 1,
"perPage": 50,
"totalPages": 5
}
}
Manual Paginationโ
- TypeScript
- Python
// First page
const page1 = await client.assets.list({ page: 1, perPage: 50 });
console.log(`Page 1: ${page1.data.length} assets of ${page1.pagination.total}`);
// Next page
if (page1.pagination.page < page1.pagination.totalPages) {
const page2 = await client.assets.list({ page: 2, perPage: 50 });
}
# First page
page1 = client.assets.list(page=1, per_page=50)
print(f"Page 1: {len(page1['data'])} assets of {page1['pagination']['total']}")
# Next page
if page1["pagination"]["page"] < page1["pagination"]["total_pages"]:
page2 = client.assets.list(page=2, per_page=50)
Auto-Paginationโ
For convenience, both SDKs provide iterators that handle pagination automatically:
- TypeScript
- Python
// AsyncGenerator โ fetches pages on demand
for await (const asset of client.assets.listAll()) {
console.log(asset.id);
}
// Collect all into an array
const allAssets: Asset[] = [];
for await (const asset of client.assets.listAll()) {
allAssets.push(asset);
}
# Iterator โ fetches pages on demand
for asset in client.assets.list_all():
print(asset["id"])
# Collect all into a list
all_assets = list(client.assets.list_all())
Performance
Auto-pagination fetches one page at a time, only when the iterator advances. It does not pre-load all pages into memory.