Skip to main content
All list endpoints return paginated results. You control pagination using query parameters, and the response includes metadata to help you navigate through pages.

Query Parameters

ParameterTypeDefaultDescription
pageinteger1Page number (1-indexed)
pageSizeinteger50Number of items per page (max 100)

Example

# Get page 2 with 25 items per page
curl -X GET "https://api.maxcare.ai/v1/patients?page=2&pageSize=25" \
  -H "Authorization: Bearer max_prd_ak_SBA...01S" \
  -H "X-Organization-Id: org_abc123"

Response Format

Every paginated response includes a pagination object alongside the data:
{
  "code": "success",
  "data": {
    "patients": [
      {
        "id": "pat_01J5K8N2XRQV3M7YGWT4HB6E9C",
        "firstName": "Sarah",
        "lastName": "Johnson",
        "dateOfBirth": "1985-03-15"
      },
      {
        "id": "pat_01J5K8P4YRQV3M7YGWT4HB6E9D",
        "firstName": "Michael",
        "lastName": "Chen",
        "dateOfBirth": "1972-11-28"
      }
    ],
    "pagination": {
      "page": 2,
      "pageSize": 25,
      "totalCount": 142,
      "totalPages": 6
    }
  }
}

Pagination Fields

FieldTypeDescription
pagenumberCurrent page number
pageSizenumberNumber of items per page
totalCountnumberTotal number of items across all pages
totalPagesnumberTotal number of pages

Iterating Through All Pages

To fetch all records, loop until page equals totalPages:
async function fetchAllPatients(apiKey, orgId) {
  const patients = [];
  let page = 1;
  let totalPages = 1;

  while (page <= totalPages) {
    const response = await fetch(
      `https://api.maxcare.ai/v1/patients?page=${page}&pageSize=100`,
      {
        headers: {
          "Authorization": `Bearer ${apiKey}`,
          "X-Organization-Id": orgId,
        },
      }
    );
    const json = await response.json();

    patients.push(...json.data.patients);
    totalPages = json.data.pagination.totalPages;
    page++;
  }

  return patients;
}

Tips

  • Use the largest pageSize that makes sense for your use case (max 100) to minimize the number of requests.
  • The first page is page=1, not page=0.
  • An empty page returns an empty array with totalCount: 0.
  • Some list endpoints support search filters (e.g., ?search=smith on /v1/patients). Pagination applies after filtering.