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

# Pagination

> How to paginate through list endpoints

All list endpoints return paginated responses with a consistent format.

## Response Format

```json theme={null}
{
  "data": [...],
  "pagination": {
    "total": 142,
    "limit": 25,
    "offset": 0,
    "has_more": true
  }
}
```

| Field      | Description                                    |
| ---------- | ---------------------------------------------- |
| `total`    | Total number of results matching your query    |
| `limit`    | Number of results per page                     |
| `offset`   | Number of results skipped                      |
| `has_more` | Whether there are more results after this page |

## Query Parameters

| Parameter | Default           | Max | Description                |
| --------- | ----------------- | --- | -------------------------- |
| `limit`   | 25                | 100 | Number of results per page |
| `offset`  | 0                 | -   | Number of results to skip  |
| `sort`    | `created_at:desc` | -   | Sort field and direction   |

## Sorting

Use the `sort` parameter with the format `field:direction`:

```bash theme={null}
# Newest first (default)
GET /events?sort=created_at:desc

# Alphabetical by title
GET /events?sort=title:asc
```

Each endpoint supports specific sort fields — refer to the API reference for details.

## Paginating Through All Results

<CodeGroup>
  ```javascript Node.js theme={null}
  async function fetchAll(url, headers) {
    const results = [];
    let offset = 0;
    const limit = 100;

    while (true) {
      const response = await fetch(`${url}?limit=${limit}&offset=${offset}`, { headers });
      const { data, pagination } = await response.json();
      results.push(...data);

      if (!pagination.has_more) break;
      offset += limit;
    }

    return results;
  }

  const events = await fetchAll('https://api.tickable.io/events', {
    'Authorization': 'Bearer tk_live_YOUR_API_KEY'
  });
  ```

  ```python Python theme={null}
  import requests

  def fetch_all(url, headers):
      results = []
      offset = 0
      limit = 100

      while True:
          response = requests.get(url, headers=headers, params={
              'limit': limit,
              'offset': offset
          })
          body = response.json()
          results.extend(body['data'])

          if not body['pagination']['has_more']:
              break
          offset += limit

      return results

  events = fetch_all('https://api.tickable.io/events', {
      'Authorization': 'Bearer tk_live_YOUR_API_KEY'
  })
  ```
</CodeGroup>

<Tip>
  Use the maximum `limit=100` when fetching all results to minimize the number of API calls.
</Tip>
