Pages of results
Read long lists a piece at a time.
These calls give long lists a page at a time: /links, /links/{id}/clicks, /campaigns, /people, /sales and /automations. They take limit (1 to 100, starts as 50) and cursor. The answer has next_cursor.
Read every sale
async function allSales(key: string) {
const sales: unknown[] = [];
let cursor: string | null = null;
do {
const url = new URL("https://api.usetotems.com/v1/sales");
url.searchParams.set("limit", "100");
if (cursor) url.searchParams.set("cursor", cursor);
const res = await fetch(url, { headers: { Authorization: `Bearer ${key}` } });
if (!res.ok) throw new Error(await res.text());
const page = (await res.json()) as { data: unknown[]; next_cursor: string | null };
sales.push(...page.data);
cursor = page.next_cursor;
} while (cursor);
return sales;
}When next_cursor is null, you have everything. Don't change a cursor.
A changed or cut cursor gives status 400 with the code bad_cursor.
Some lists are short by nature and come whole, with no cursor: /channels, /content, /domains and /health. /hot-leads takes a limit up to 100. A person's journey and notes give the newest 300 and 200. A run list gives the last 100.
Was this useful?
Your answer stays in this browser.
Last checked: 2026-12-03Plain MarkdownSomething wrong? Tell us