Pagination
Updated
List tools return one page at a time, and you move forward with an opaque cursor.
limit and cursor
limit: rows per page, 1 to 100, default 25. Some sources return fewer than you ask for. X pages hold about 20.cursor: thepage.nextCursorfrom the previous response. Treat it as opaque and never build one yourself.page.hasMore: false on the last page.
A cursor only works with the parameters it came from. If you change q, sort or any other input and send an old cursor, you get invalid_input.
Looping through pages
// Fetch every page of a Reddit search, stopping when hasMore is false.
let cursor = null;
let spent = 0;
do {
const url = new URL("https://api.chatterapi.com/v1/reddit/search");
url.searchParams.set("q", "crm recommendation");
url.searchParams.set("limit", "25");
if (cursor) url.searchParams.set("cursor", cursor);
const res = await fetch(url, { headers: { Authorization: `Bearer ${process.env.CHATTERAPI_KEY}` } });
const body = await res.json();
if (!res.ok) throw new Error(`${body.error.code}: ${body.error.message}`);
spent += body.credits.charged;
for (const post of body.data) console.log(post.title);
cursor = body.page.hasMore ? body.page.nextCursor : null;
} while (cursor);
console.log("credits spent:", spent);Each page is one charge
Each page is billed separately at the tool's price, so set a page budget for large exports. The X follower exporters list their page size as the unit next to the price.
Cursors expire
Cursors may expire after a while, since the platforms' own cursors do. An expired cursor returns invalid_input with the message cursor: invalid or expired cursor, and you have to start again from the first page.