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

# Pagination

> How to paginate through list endpoints

# Pagination

All list endpoints in the RxScale APIs support pagination through query parameters.

## Query Parameters

| Parameter | Type    | Default | Description                |
| --------- | ------- | ------- | -------------------------- |
| `page`    | integer | `0`     | Page number (zero-indexed) |
| `limit`   | integer | `50`    | Number of items per page   |

<Warning>
  Pages are **zero-indexed**. The first page is `page=0`, not `page=1`.
</Warning>

## Response Format

Paginated endpoints return:

```json theme={null}
{
  "data": [...],
  "totalRegistries": 150,
  "totalPages": 3
}
```

* `data` — Array of items for the current page
* `totalRegistries` — Total number of items across all pages
* `totalPages` — Total number of pages (calculated as `ceil(totalRegistries / limit)`)

## Limits

| API                   | Default Limit | Maximum Limit |
| --------------------- | ------------- | ------------- |
| External Pharmacy API | 50            | 200           |
| Management API        | 50            | 200           |
| Public API (Products) | 50            | 150           |

Requesting a `limit` above the maximum will be capped to the maximum.

## Example

Fetching the second page of 25 products:

```bash theme={null}
curl -X GET "https://api.rxscale.com/v1/management/products?page=1&limit=25" \
  -H "X-API-Key: your-api-key"
```

Response:

```json theme={null}
{
  "data": [
    {"uid": "prod_abc", "name": "Product 26"},
    {"uid": "prod_def", "name": "Product 27"}
  ],
  "totalRegistries": 75,
  "totalPages": 3
}
```

## Iterating Through All Pages

```python theme={null}
import requests

page = 0
all_items = []

while True:
    response = requests.get(
        "https://api.rxscale.com/v1/management/products",
        headers={"X-API-Key": "your-api-key"},
        params={"page": page, "limit": 50}
    )
    data = response.json()
    all_items.extend(data["data"])

    if page >= data["totalPages"] - 1:
        break
    page += 1
```

<Tip>
  Use the smallest `limit` that makes sense for your use case. Smaller pages mean faster responses and less memory usage.
</Tip>
