Pagination, filtering and ordering

How to walk through lists with page and page_size, filter and order results, and sync changes incrementally with updated_after.

Pagination

List endpoints return a page of results in this format:

{
  "count": 123,
  "next": "https://api.billora.app/api/v1/invoices/?page=3&page_size=50",
  "previous": "https://api.billora.app/api/v1/invoices/?page=1&page_size=50",
  "results": [ { "id": 5120, "number": "F-2026-0001" } ]
}
JSON
ParameterDefaultDescription
page1Page number, starting at 1.
page_size50Items per page, up to 200 (larger values are capped at 200).
  • count is the total number of items matching the filters.
  • next and previous are full URLs (or null). To walk a list, follow next until it is null instead of building URLs yourself.
  • A page out of range returns 404 not_found.

Some lists (products, units, payments…) historically returned a plain array in the web app. With an API key they always use the paginated format above.

async function* listAll(path) {
  let url = `https://api.billora.app/api/v1${path}`;
  while (url) {
    const res = await fetch(url, { headers: { Authorization: `Bearer ${process.env.BILLORA_API_KEY}` } });
    if (!res.ok) throw new Error(`HTTP ${res.status}`);
    const page = await res.json();
    yield* page.results;
    url = page.next;
  }
}
 
for await (const customer of listAll("/customers/?page_size=200")) {
  console.log(customer.id, customer.legal_name);
}
JavaScript

Filters

Filters are query string parameters. Invalid values (a malformed date, a non-numeric id) return 400 validation_error, never a surprisingly empty list.

Filters shared by every public resource

ParameterExampleReturns items…
created_after2026-10-01created at or after that date/time
created_before2026-10-31T23:59:59Zcreated before that date/time
updated_after2026-11-01T08:00:00Zchanged at or after that date/time
updated_before2026-11-01changed before that date/time
searchtallerescontaining the text in their search fields (number, name, tax id, notes…)
ordering-created_atordered by that field (see below)

They accept a date (YYYY-MM-DD) or an ISO 8601 date-time with offset. A date without time means 00:00 that day in Spanish mainland time (Europe/Madrid). *_after filters are inclusive (>=) and *_before ones exclusive (<), so ranges chain without overlap.

Per-resource filters

Each resource adds its own; the full list is in the reference. For example, on /invoices/:

ParameterDescription
statusdraft, sent, partially_paid, paid, overdue, rectified, cancelled…
customerCustomer id.
numberNumber contains this text.
date_from / date_toIssue date from / to (YYYY-MM-DD).
total_min / total_maxTotal including tax between those amounts.
is_rectifyingtrue to list only corrective invoices.
is_simplifiedtrue to list only simplified invoices.
curl "https://api.billora.app/api/v1/invoices/?status=overdue&date_from=2026-01-01&ordering=due_date" \
  -H "Authorization: Bearer $BILLORA_API_KEY"
bash

Ordering

ordering takes a field name; prefix it with - for descending order. Combine several with commas: ordering=-issue_date,number. Each resource documents which fields it accepts; for sales documents they are issue_date, number, total and created_at (default -issue_date,-number).

Incremental sync

To keep a copy of the data in your system (ERP, BI, CRM), don't download everything every time: ask only for what changed since the last sync with updated_after.

  1. Store the sync start time before you start requesting data.
  2. Request updated_after=<last sync> with a stable order (ordering=created_at) and walk every page.
  3. Upsert by id in your database.
  4. When you finish without errors, store the time from step 1 as the new “last sync”.

Subtracting a few minutes from the previous mark avoids missing changes committed right during the sync; since you upsert by id, processing an item twice has no effect.

import { setTimeout as sleep } from "node:timers/promises";
 
const API = "https://api.billora.app/api/v1";
const headers = { Authorization: `Bearer ${process.env.BILLORA_API_KEY}` };
 
export async function syncInvoices(db) {
  const startedAt = new Date();
  const since = await db.getCursor("invoices"); // ISO string or null
  const margin = since ? new Date(new Date(since).getTime() - 5 * 60_000).toISOString() : null;
 
  let url = `${API}/invoices/?page_size=200&ordering=created_at` + (margin ? `&updated_after=${encodeURIComponent(margin)}` : "");
  while (url) {
    const res = await fetch(url, { headers });
    if (res.status === 429) {
      await sleep(Number(res.headers.get("Retry-After") ?? 5) * 1000);
      continue;
    }
    if (!res.ok) throw new Error(`HTTP ${res.status} ${res.headers.get("X-Request-Id")}`);
    const page = await res.json();
    for (const invoice of page.results) await db.upsertInvoice(invoice);
    url = page.next;
  }
  await db.setCursor("invoices", startedAt.toISOString());
}
JavaScript

Combine it with webhooks

Incremental sync is the safety net; webhooks tell you instantly. The most robust setup uses both: process webhooks in real time and run the sync periodically to recover any missed event.

Deletions don't show up in updated_after (the item no longer exists). To mirror them, listen to the *.deleted events or compare ids periodically.