Skip to content

Getting started

Pagination

List orders returns pages, newest first. Cursors are stable while new orders arrive: you never see an order twice or skip one.

Cursors

limit
Page size, 1–100. Defaults to 25.
cursor
Pass the previous page’s next_cursor to get the next one. Omit for the first page.
data
The orders on this page.
has_more
Whether there is another page.
next_cursor
Opaque string for the next page, or null on the last page.

Treat cursors as opaque: don’t build or edit them. Filters such as status must stay the same across the pages of one walk.

Walking every page

async function* allOrders(params = {}) {
  let cursor = null;
  do {
    const query = new URLSearchParams({ limit: "100", ...params, ...(cursor ? { cursor } : {}) });
    const res = await fetch(`https://passcode.sh/api/v1/orders?${query}`, {
      headers: { Authorization: `Bearer ${process.env.PASSCODE_API_KEY}` },
    });
    const page = await res.json();
    yield* page.data;
    cursor = page.next_cursor;
  } while (cursor);
}

for await (const order of allOrders({ status: "completed" })) {
  console.log(order.id, order.code);
}

Other lists

  • Services and countries return the full list in one response.
  • Rentals return your 100 most recent.
  • Rental messages take a limit up to 500, newest first.