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

ParameterTypeDescription
limitintegerObjects per page, from 1 to 100. Defaults to 25.
cursorstringAn 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
}
  • data holds this page's objects.
  • has_more is true when another page exists.
  • next_cursor is the cursor for the next page, or null on 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"]