Pagination and expanding
Lists are cursor based, so a page never skips or repeats an object that is made while you read.
Lists
{ "object": "list", "url": "/v1/invoices", "has_more": true, "data": [ { "id": "inv_…" } ] }
limitis 1 to 100, default 20.- Results are newest first. To get the next page, send
starting_after=<id of the last object you got>. Stop whenhas_moreisfalse. - Filters are plain query parameters, for example
status=paidorcustomer=cus_…. Each list in the reference names its filters.
curl "https://api.invoicing.respiresoft.com/v1/invoices?limit=100&starting_after=inv_abc" \
-H "Authorization: Bearer $RESPIRESOFT_KEY"let after
do {
const url = new URL("https://api.invoicing.respiresoft.com/v1/invoices")
url.searchParams.set("limit", "100")
if (after) url.searchParams.set("starting_after", after)
const page = await (await fetch(url, { headers: { Authorization: `Bearer ${process.env.RESPIRESOFT_KEY}` } })).json()
for (const invoice of page.data) console.log(invoice.id)
after = page.has_more ? page.data.at(-1).id : null
} while (after)$after = null;
do {
$url = "https://api.invoicing.respiresoft.com/v1/invoices?limit=100" . ($after ? "&starting_after=$after" : "");
$ch = curl_init($url);
curl_setopt_array($ch, [CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => ["Authorization: Bearer " . getenv("RESPIRESOFT_KEY")]]);
$page = json_decode(curl_exec($ch), true);
foreach ($page["data"] as $invoice) echo $invoice["id"], "\n";
$after = $page["has_more"] ? end($page["data"])["id"] : null;
} while ($after);import os, requests
after = None
while True:
params = {"limit": 100, **({"starting_after": after} if after else {})}
page = requests.get("https://api.invoicing.respiresoft.com/v1/invoices", params=params,
headers={"Authorization": "Bearer " + os.environ["RESPIRESOFT_KEY"]}).json()
for invoice in page["data"]:
print(invoice["id"])
if not page["has_more"]:
break
after = page["data"][-1]["id"]Events are different
GET /v1/events?after=<evt_id> returns events newer than that one, oldest first, so you can process them in order and keep the last id as your cursor. Without after it behaves like every other list.
Expanding
Related objects show as ids. Ask for the whole object with expand[], for example GET /v1/invoices/inv_…?expand[]=customer. Each reference page lists what can be expanded.