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

# Paginating Sportrix Data API List Endpoint Responses

> Sportrix Data list endpoints return paginated results using limit and offset. Learn how to page through leagues and matches using the pagination envelope.

List endpoints in Sportrix Data return results in pages. Rather than receiving every matching record in a single response, you request a window of results using `limit` and `offset` and check the envelope metadata to know whether more pages exist. This keeps individual responses fast and predictable regardless of how many records match your query.

## Which endpoints are paginated

The following endpoints are paginated and accept `limit` and `offset`:

* `GET /leagues`
* `GET /leagues/active`
* `GET /matches`
* `GET /matches/active`

<Note>
  `GET /sports` is **not paginated** — it returns a bare array containing only your enabled sports, which is a small, bounded list. Single-item endpoints (`GET /matches/{id}`, `GET /matches/{id}/live`, `GET /matches/{id}/result`) also return the object directly, not an envelope.
</Note>

## Pagination parameters

| Param    | Default | Max   | Description                                                              |
| -------- | ------- | ----- | ------------------------------------------------------------------------ |
| `limit`  | `100`   | `200` | Number of items to return per page. Values above 200 are clamped to 200. |
| `offset` | `0`     | —     | Number of items to skip before the first result on this page.            |

## Pagination envelope

Every paginated response wraps its results in a **pagination envelope** with the following fields:

| Field         | Type    | Description                                                 |
| ------------- | ------- | ----------------------------------------------------------- |
| `items`       | array   | The records for this page                                   |
| `total`       | integer | Total records matching the query, across all pages          |
| `limit`       | integer | Page size used for this response (after clamping)           |
| `offset`      | integer | Number of records skipped                                   |
| `count`       | integer | Number of records in this page (`items.length`)             |
| `page`        | integer | 1-based page number for this `offset` / `limit` combination |
| `total_pages` | integer | Total number of pages at the current `limit`                |
| `has_more`    | boolean | `true` if more records exist beyond this page               |

### Example response

```json theme={null}
{
  "items": [ ],
  "total": 137,
  "limit": 100,
  "offset": 0,
  "count": 100,
  "page": 1,
  "total_pages": 2,
  "has_more": true
}
```

## Paging through all results

The simplest pagination strategy is to increment `offset` by `limit` on each request and stop when `has_more` is `false`. Here is a complete Python example that fetches every league for a given sport:

```python theme={null}
import requests

HEADERS = {"X-API-Key": "sk_your_api_key_here"}
BASE = "https://api.sportrixdata.com/api"

offset = 0
limit = 100
all_leagues = []

while True:
    r = requests.get(
        f"{BASE}/leagues",
        params={"sport": 1, "limit": limit, "offset": offset},
        headers=HEADERS,
    )
    page = r.json()
    all_leagues.extend(page["items"])
    if not page["has_more"]:
        break
    offset += limit

print(f"Fetched {len(all_leagues)} leagues")
```

You can apply the same pattern to `GET /matches` by replacing the `sport` parameter with `league` and adjusting your filter parameters as needed.
