Pagination & filtering
List endpoints in the Luna Health API return results in pages so you can retrieve large collections efficiently. Because the API is read-only, you page and filter entirely with GET query parameters — there is no request body.
Page through results
Request one page at a time and keep requesting until a page comes back short (or the response signals there is no next page). The exact parameters this API accepts are listed in Supported parameters below and on each endpoint's reference page.
# Fetch the first page, then the next, adjusting the query parameters
curl "https://account.lunahealth.app/api/appointments?limit=50" \
-H "Authorization: Bearer YOUR_API_KEY"async function fetchAll(url, apiKey) {
const results = [];
let offset = 0;
const limit = 50;
for (;;) {
const res = await fetch(`${url}?limit=${limit}&offset=${offset}`, {
headers: { Authorization: `Bearer ${apiKey}` },
});
const page = await res.json();
const items = Array.isArray(page) ? page : page.data ?? [];
results.push(...items);
if (items.length < limit) break;
offset += limit;
}
return results;
}import requests
def fetch_all(url, api_key, limit=50):
results, offset = [], 0
while True:
res = requests.get(
url,
params={"limit": limit, "offset": offset},
headers={"Authorization": f"Bearer {api_key}"},
)
page = res.json()
items = page if isinstance(page, list) else page.get("data", [])
results.extend(items)
if len(items) < limit:
break
offset += limit
return resultsFilter results
Narrow a list by adding filter query parameters — for example a date range, a status, or a search term. Combine filters with pagination to keep responses small and fast. The filters available on each endpoint are documented on that endpoint's reference page.
Best practices
- Request only what you need: use filters and a reasonable page size instead of fetching everything.
- Handle partial pages gracefully — stop when a page returns fewer items than the page size.
- Cache results where appropriate and respect any rate limits returned in response headers.
Supported parameters
| Name | Type | Description |
|---|---|---|
end_date | string | — |
from | string (date-time) | — |
limit | number | — |
page | number | — |
query | string | — |
start_date | string | — |
status | string | — |
to | string (date-time) | — |