Pagination
Cursor, page, and limit in Admin and Storefront lists.
Admin lists and Storefront account lists use cursor pagination. The Storefront
catalog (GET /) uses page numbers. Each operation in the reference
shows which one it uses.
| Scheme | Parameters | Where |
|---|---|---|
| Cursor | cursor, limit | Almost every Admin list; on Storefront, reviews, customer orders, and store locations. |
| Page | page, pageSize | Storefront GET / and Admin GET /. |
| Limit | limit | Short lists with no next page: related products, recommendations, and geographic areas. |
Cursor
Request the first page without cursor. For the next one, send the previous
response's nextCursor with the same filters and sort.
curl "https://api.ecomiq.pe/api/v1/catalog/brands?limit=50" \
-H "Authorization: Bearer $ECOMIQ_TOKEN"{
"data": [{ "id": "7204558912004324355", "name": "Andes" }],
"hasNextPage": true,
"nextCursor": "eyJpZCI6IjcyMDQ1NTg5MTIwMDQzMjUzMDEifQ",
"totalCount": 132
}| Parameter | Value |
|---|---|
limit | 1 to 200. If you omit it, most lists return 20. |
cursor | The previous page's nextCursor. Omit it on the first page. |
sortBy | Sort field; each operation lists the accepted values. |
sortDirection | asc or desc. |
search | Free text. |
| Field | Meaning |
|---|---|
data | The items on this page. |
hasNextPage | true when at least one more page remains. |
nextCursor | Cursor for the next page; null on the last one. |
totalCount | Total matches. May be null. |
Some lists cap the page below 200, for example at 100, and return at most that
many items even if you ask for more. A limit outside 1–200 returns 400. A
cursor that can't be read returns 400 with Common.InvalidCursor.
async function* walkByCursor(firstUrl: URL, token: string) {
let cursor: string | null = null;
do {
const url = new URL(firstUrl);
if (cursor) url.searchParams.set("cursor", cursor);
const response = await fetch(url, {
headers: { Authorization: `Bearer ${token}` },
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const page = await response.json();
yield* page.data;
cursor = page.hasNextPage ? page.nextCursor : null;
} while (cursor);
}Page
page starts at 1. On Storefront GET /, pageSize ranges from 1
to 100 (24 by default) and page goes up to 100.
curl "https://storefront.ecomiq.pe/v1/products?page=2&pageSize=24" \
-H "x-Store-Domain: my-store"The response includes pageIndex, pageSize, totalCount, and totalPages,
with the items in products. Keep increasing page while pageIndex is lower
than totalPages.
Admin GET / returns data, pageIndex,
totalPages, hasPreviousPage, and hasNextPage; there pageSize ranges
from 1 to 100.
Limit only
These operations return a short list and have no next page. limit sets how
many items you want; to walk the whole resource, use its cursor list.
Last updated: