Pagination
Navigate large result sets with pagination.
Overview
List endpoints return paginated results. Use query parameters to navigate through large datasets.
Query Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
page | integer | 1 | Page number (1-based) |
per_page | integer | 25 | Items per page (max: 100) |
Example
curl -X GET "https://api.whatalo.com/v1/products?page=2&per_page=50" \
-H "X-API-Key: wk_live_your_key_here"Response Metadata
Every list response includes pagination metadata:
{
"data": [...],
"pagination": {
"page": 2,
"per_page": 50,
"total": 142,
"total_pages": 3
}
}Iterating All Pages
async function fetchAllProducts() {
const allProducts = [];
let page = 1;
let hasMore = true;
while (hasMore) {
const res = await fetch(
`https://api.whatalo.com/v1/products?page=${page}&per_page=100`,
{ headers: { 'X-API-Key': API_KEY } }
);
const { data, pagination } = await res.json();
allProducts.push(...data);
hasMore = page < pagination.total_pages;
page++;
}
return allProducts;
}Best Practices
- Use
per_page=100for bulk operations to minimize requests - Use
total_pagesto detect when you have reached the last page - Don't fetch all pages at once — implement lazy loading in UIs
- Use count endpoints (
/products/count) when you only need the total