Pagination
Cursor pagination for lists — stable under inserts, no page numbers.
GET /v1/orders returns orders newest first, one page at a time:
200 OK
{
"items": [ { "id": "0192f1b2-…", "external_id": "SHOP-100245", "status": "to_dropoff" } ],
"next_cursor": "YzF8MDE5MmYxYjItNmQ0ZS03YTEwLWIzYzItOGUxZjBkOWE0YzU3"
}| Parameter | Meaning |
|---|---|
limit | page size, 1–200, default 50 |
cursor | next_cursor of the previous page; omit for the first page |
status, from, to, point_id | filters — keep them the same on every page |
next_cursor is null on the last page. The cursor is opaque: do not parse or build it — a changed cursor gives
400 invalid_cursor. New orders created while you page do not shift the pages (keyset pagination).
async function* allOrders(params = {}) {
let cursor;
do {
const q = new URLSearchParams({ ...params, limit: "200", ...(cursor ? { cursor } : {}) });
const page = await fetch(`https://partner.sapamoto.kz/v1/orders?${q}`, {
headers: { Authorization: `Bearer ${process.env.SAPA_KEY}` },
}).then((r) => r.json());
yield* page.items;
cursor = page.next_cursor;
} while (cursor);
}
for await (const order of allOrders({ from: "2026-10-24T00:00:00+05:00" })) console.log(order.external_id);def all_orders(**filters):
cursor = None
while True:
params = {**filters, "limit": 200, **({"cursor": cursor} if cursor else {})}
page = requests.get("https://partner.sapamoto.kz/v1/orders", params=params,
headers={"Authorization": f"Bearer {KEY}"}, timeout=10).json()
yield from page["items"]
cursor = page["next_cursor"]
if not cursor:
return