Pagination
How to paginate through large result sets
Endpoints that return lists of resources support pagination to help you work with large datasets efficiently.
Pagination Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
limit | integer | 20 | Number of results per page (1-100) |
page | integer | 1 | Page number to retrieve (1-based) |
Example Request
curl "https://api.emfas.ai/v1/products?limit=50&page=2" \
-H "Authorization: Bearer YOUR_API_KEY"Response Structure
Paginated responses return a result array containing the requested items:
{
"result": [
{
"identifier": "PROD-001",
"name": "Example Product"
},
{
"identifier": "PROD-002",
"name": "Another Product"
}
]
}Iterating Through Pages
To fetch all results, increment the page number until you receive fewer results than your limit:
async function fetchAllProducts(apiKey) {
const products = [];
let page = 1;
const limit = 100;
while (true) {
const response = await fetch(
`https://api.emfas.ai/v1/products?limit=${limit}&page=${page}`,
{ headers: { 'Authorization': `Bearer ${apiKey}` } }
);
const { result } = await response.json();
products.push(...result);
if (result.length < limit) {
break;
}
page++;
}
return products;
}Incremental Sync
For syncing changes since your last fetch, use the updated_after parameter with a timestamp:
curl "https://api.emfas.ai/v1/products?updated_after=2024-01-15T10:30:00Z" \
-H "Authorization: Bearer YOUR_API_KEY"This returns only items modified after the specified time, useful for keeping an external system in sync without fetching your entire catalog each time. The timestamp must be in RFC3339 format (e.g., 2024-01-15T10:30:00Z).
Hierarchy-aware filtering
The updated_after filter includes changes from parent levels in the hierarchy:
| Endpoint | Catches changes on |
|---|---|
/products?updated_after=X | Product |
/variants?updated_after=X | Variant, Product |
/skus?updated_after=X | SKU, Variant, Product |
We recommend fetching from the lowest level your organization uses. For example, if you use products and variants, fetch from /variants?updated_after=X to capture changes at both levels.
Store the timestamp of each successful sync and use it for the next request to minimize data transfer.