Pagination
All list endpoints return paginated results with a consistent format.
Query Parameters
| Param | Type | Default | Description |
|---|---|---|---|
page | number | 1 | Page number (1-based) |
limit | number | 20 | Items per page (max 250) |
sortBy | string | created_at | Field to sort by |
sortOrder | string | desc | asc or desc |
GET /stores/:storeId/products?page=2&limit=50&sortBy=title&sortOrder=asc
Response Format
Every paginated response includes the same envelope:
{
"data": [
{ "id": "prod_abc123", "title": "Product A" },
{ "id": "prod_def456", "title": "Product B" }
],
"total": 150,
"page": 2,
"limit": 50,
"totalPages": 3
}
| Field | Description |
|---|---|
data | Array of resource objects |
total | Total number of matching records |
page | Current page number |
limit | Items per page |
totalPages | Total number of pages |
SDK Usage
Manual Pagination
const page1 = await tanqory.products.list(storeId, { page: 1, limit: 50 })
console.log(page1.total) // 150
console.log(page1.totalPages) // 3
const page2 = await tanqory.products.list(storeId, { page: 2, limit: 50 })
Auto-Pagination
Use listAll() to iterate through every page automatically:
for await (const product of tanqory.products.listAll(storeId)) {
console.log(product.title)
}
The SDK fetches the next page when the current page is exhausted. This works on all list endpoints:
for await (const order of tanqory.orders.listAll(storeId, { status: 'UNFULFILLED' })) {
await processOrder(order)
}
Collect All Results
const allProducts: Tanqory.Product[] = []
for await (const product of tanqory.products.listAll(storeId)) {
allProducts.push(product)
}
Sorting
Common sortable fields by resource:
| Resource | sortBy values |
|---|---|
| Products | created_at, updated_at, title, price, inventory |
| Orders | created_at, updated_at, total, order_number |
| Customers | created_at, updated_at, name, orders_count, total_spent |