> ## Documentation Index
> Fetch the complete documentation index at: https://docs.teamcaredental.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Paginating TeamCare API Responses

> TeamCare uses cursor-based pagination (after parameter) for large datasets and page-based pagination for smaller ones. Max page size is 5000 items.

TeamCare APIs return large datasets in pages. The pagination mode depends on the endpoint. Cursor-based pagination is used for large, dynamic datasets such as appointments, treatments, patients, ledger transactions, and patient referrals. Page-based pagination is used for all other endpoints.

## Pagination modes

### Cursor-based pagination

Cursor-based pagination uses the `after` parameter, which holds the ID of the last item from the previous page. This approach is more stable for datasets that change between requests because it avoids the duplicates and skips that can occur with page numbers.

To use cursor-based pagination:

1. Make an initial request without the `after` parameter.
2. Extract the last item's ID from the response.
3. Pass that ID as the `after` query parameter in the next request.

### Page-based pagination

Page-based pagination uses the `page` query parameter to request a specific page number. This is suitable for smaller or more stable datasets.

## Page size limit

You can request up to **5,000 items per page** using the `items` query parameter. Requests that exceed this limit will be capped to 5,000.

## Cursor-based request example

```bash theme={null}
curl "https://app.teamcaredental.com/api/v1/vendors/patients?after=abc123&items=1000" \
  -H "Authorization: Bearer <your-token>"
```

In this example, `after=abc123` tells the API to return the next set of results starting after the patient with ID `abc123`, and `items=1000` limits the response to 1,000 records.

<Note>
  Cursor-based pagination is recommended for large datasets because page numbers can shift if records are added or removed between requests.
</Note>
