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

# Pagination

> How to paginate through large result sets

The transactions endpoint supports page-based pagination for large result sets. Other endpoints return all results in a single response.

***

## Paginated endpoints

| Endpoint                     | Default behavior                                                                                 |
| ---------------------------- | ------------------------------------------------------------------------------------------------ |
| `GET /v1/users/transactions` | Returns all transactions if `page` is omitted. Use `page` and `page_size` for paginated results. |
| `GET /v1/links`              | Returns all links with `count`, `next`, and `previous` fields.                                   |

***

## Request parameters

| Parameter   | Type    | Description                                               |
| ----------- | ------- | --------------------------------------------------------- |
| `page`      | integer | Page number (1-based). Omit to fetch all results at once. |
| `page_size` | integer | Number of results per page. Min 10, max 500. Default 500. |

### Example request

```bash theme={null}
curl -H "Authorization: Bearer $ACCESS_TOKEN" \
  "https://api.mytruv.com/v1/users/transactions?transacted_at_from=2025-01-01&page=1&page_size=50"
```

***

## Response format

Paginated responses include navigation fields alongside the data:

```json theme={null}
{
  "count": 1250,
  "next": "https://api.mytruv.com/v1/users/transactions?page=2&page_size=50",
  "previous": null,
  "transactions": [...],
  "accounts": [...],
  "daily_totals": [...]
}
```

| Field      | Type           | Description                                            |
| ---------- | -------------- | ------------------------------------------------------ |
| `count`    | integer        | Total number of results across all pages               |
| `next`     | string or null | URL for the next page, `null` if on the last page      |
| `previous` | string or null | URL for the previous page, `null` if on the first page |

***

## Iterating through pages

To retrieve all results, follow the `next` URL until it returns `null`.

```python theme={null}
import requests

url = "https://api.mytruv.com/v1/users/transactions"
params = {"transacted_at_from": "2025-01-01", "page": 1, "page_size": 100}
all_transactions = []

headers = {"Authorization": f"Bearer {ACCESS_TOKEN}"}

while url:
    response = requests.get(url, params=params, headers=headers)
    data = response.json()
    all_transactions.extend(data["transactions"])
    url = data.get("next")
    params = {}  # next URL includes all parameters
```
