GetbeelDocs

Pagination

Lists use cursor pagination with limit, cursor, has_more and next_cursor.

Endpoints that return lists (GET /invoices, GET /received-invoices) are sorted by invoice_date, newest first, and return one page at a time:

{
  "object": "list",
  "data": [{ "object": "invoice", "id": "fe_3f1c…" }],
  "has_more": true,
  "next_cursor": "WyIyMDI2LTEwLTE1IiwiZmVfM2YxYyJd"
}
ParameterDescription
limitItems per page, 1 to 100. Default 20
cursorThe next_cursor of the previous page

When has_more is false, next_cursor is null and you have read everything. The cursor is opaque: don't build it yourself. Repeat filters (for example status, date_from, date_to) on every page.

Reading every page

async function* allInvoices(params = {}) {
  let cursor;

  do {
    const query = new URLSearchParams({
      ...params,
      limit: '100',
      ...(cursor ? { cursor } : {}),
    });
    const res = await fetch(
      `https://www.getbeel.com/api/v1/invoices?${query}`,
      {
        headers: { Authorization: `Bearer ${process.env.GETBEEL_API_KEY}` },
      },
    );
    const page = await res.json();

    yield* page.data;
    cursor = page.has_more ? page.next_cursor : undefined;
  } while (cursor);
}

for await (const invoice of allInvoices({ status: 'rejected' })) {
  console.log(invoice.number, invoice.sdi.error_message);
}

On this page