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
updated_after filters by the timestamp that reflects everything in the entity's response, so each level catches relevant changes across the full subtree:
| Endpoint | Catches changes on |
|---|---|
/products?updated_after=X | Product, its variants, its SKUs |
/variants?updated_after=X | Variant, its parent product, its SKUs |
/skus?updated_after=X | SKU, its parent variant, its parent product |
Pick the level your downstream system actually consumes. If you mirror products, fetch from /products — variant and SKU changes will surface there. If you mirror SKUs (the most common pattern for inventory sync), fetch from /skus so attribute changes inherited from parents come through.
Every response also carries selfUpdatedAt alongside updatedAt. When the two differ on the same entity, the change came from elsewhere in the hierarchy rather than the entity itself — useful when you want to skip work for purely-cascaded events.
Store the timestamp of each successful sync and use it for the next request to minimize data transfer.