Pagination
Every list is paged with an opaque cursor.
How it works
Ask for a page
Pass limit (1 to 100, default 50).
Read next_cursor
A string means there is more; null means this was the last page.
Ask for the next page
Send the cursor as cursor with the same other parameters. A cursor from another query is refused with 400 invalid_cursor.
# Node 18+: read every item row for November
let cursor = null, rows = [];
do {
const url = new URL("https://openapi.tmbill.com/v1/sales/items");
url.search = new URLSearchParams({ store_id: "1234", from: "2026-11-01", to: "2026-11-30", limit: "100", ...(cursor && { cursor }) });
const res = await fetch(url, { headers: { Authorization: `Bearer ${process.env.TMBILL_KEY}` } });
if (!res.ok) throw new Error((await res.json()).error.code);
const body = await res.json();
rows.push(...body.data);
cursor = body.next_cursor;
} while (cursor);