CaraCara API
Guides

Pagination

How to paginate through API results.

Overview

List endpoints return paginated results. Use the page and limit query parameters to navigate through results.

Parameters

ParameterDefaultMaxDescription
page1Page number (1-indexed).
limit25100Number of items per page.

Response format

Paginated responses include metadata alongside the data:

{
  "patients": [...],
  "total": 150,
  "page": 1,
  "limit": 25,
  "totalPages": 6,
  "hasMore": true
}
FieldDescription
totalTotal number of items matching the query.
pageCurrent page number.
limitItems per page.
totalPagesTotal number of pages.
hasMoreWhether there are more pages after this one.

Example: fetching all pages

async function fetchAllPatients(apiKey) {
  const patients = [];
  let page = 1;
  let hasMore = true;
 
  while (hasMore) {
    const res = await fetch(
      `https://platform.caramedical.com/api/v1/patients?page=${page}&limit=100`,
      { headers: { 'Authorization': `Bearer ${apiKey}` } }
    );
 
    const data = await res.json();
    patients.push(...data.patients);
    hasMore = data.hasMore;
    page++;
  }
 
  return patients;
}

On this page