Luna SaludAPI ReferenceLuna Salud

Pagination & filtering

List endpoints in the Luna Health API return results in pages so you can retrieve large collections efficiently. You page and filter with query parameters, as shown below.

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 results

Filter 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

Supported parameters

NameTypeDescription
datestringCalendar day as YYYY-MM-DD, in the provider's timezone
end_datestring—
fromstring (date-time)—
limitnumber—
pagenumber—
querystring—
start_datestring—
statusstring—
tostring (date-time)—