Pagination
Cursor pagination with limit, cursor, next_cursor and has_more.
Every endpoint that returns a collection is cursor-paginated. You ask for a page, and the response tells you whether another page exists and how to get it.
Parameters
| Parameter | Type | Description |
|---|---|---|
limit | integer | Objects per page, from 1 to 100. Defaults to 25. |
cursor | string | An opaque value from the previous response's next_cursor. Omit it to get the first page. |
Treat cursors as opaque. Do not parse, build or store them for long: pass back exactly what you received.
The list envelope
List response
{
"object": "list",
"data": [ { "object": "patient", "id": "..." } ],
"next_cursor": "eyJwIjoyfQ",
"has_more": true
}dataholds this page's objects.has_moreistruewhen another page exists.next_cursoris the cursor for the next page, ornullon the last page.
Fetch every page
Keep requesting until has_more is false.
Node.js (fetch)
const headers = { Authorization: `Bearer ${process.env.AVEECARE_API_KEY}` };
const all = [];
let cursor;
do {
const url = new URL('https://api.aveecare.com/v1/patients');
url.searchParams.set('limit', '100');
if (cursor) url.searchParams.set('cursor', cursor);
const page = await (await fetch(url, { headers })).json();
all.push(...page.data);
cursor = page.has_more ? page.next_cursor : undefined;
} while (cursor);Python (requests)
import os
import requests
headers = {"Authorization": f"Bearer {os.environ['AVEECARE_API_KEY']}"}
params = {"limit": 100}
items = []
while True:
page = requests.get("https://api.aveecare.com/v1/patients", headers=headers, params=params).json()
items.extend(page["data"])
if not page["has_more"]:
break
params["cursor"] = page["next_cursor"]