API reference

Pagination

List endpoints return results newest first, a page at a time, with a cursor.

Query parameters

limitinteger
How many objects to return, 1 to 100. Default 10.
starting_afterstring
A session id: return the page of objects that come after it (older).
{
  "object": "list",
  "data": [ { "id": "cs_…", "object": "checkout.session", ... } ],
  "has_more": true
}

Fetching everything

While has_more is true, pass the last id of the page as starting_after:

async function* allSessions(params = {}) {
  let startingAfter;
  for (;;) {
    const query = new URLSearchParams({ limit: "100", ...params });
    if (startingAfter) query.set("starting_after", startingAfter);
    const page = await saphra(`/checkout/sessions?${query}`);
    yield* page.data;
    if (!page.has_more) return;
    startingAfter = page.data.at(-1).id;
  }
}

for await (const session of allSessions({ status: "complete" })) {
  console.log(session.id, session.amount);
}