Skip to main content

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โ€‹

// 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 });
}

Auto-Paginationโ€‹

For convenience, both SDKs provide iterators that handle pagination automatically:

// 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);
}
Performance

Auto-pagination fetches one page at a time, only when the iterator advances. It does not pre-load all pages into memory.