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

# Pagination

> Page through End Close API list endpoints with cursor pagination (cursor, limit, next_cursor), and with offset pagination where an endpoint uses it.

End Close list endpoints return results one page at a time. Most use cursor pagination: you request a page with `limit`, and pass each response's `next_cursor` back as `cursor` until `next_cursor` is `null`.

## Cursor pagination

These endpoints use cursors:

| Endpoint | Default `limit` | Maximum `limit` |
| - | - | - |
| `GET /records` | 50 | 200 |
| `GET /file_imports` | 50 | 200 |
| `GET /data_streams/{key}/file_imports` | 50 | 200 |
| `GET /reconciliations` | 50 | 200 |
| `GET /agents` | 50 | 200 |
| `GET /agents/{id}/runs` | 50 | 200 |
| `GET /audit_events` | 50 | 200 |

Results come newest first.

### Request parameters

**limit** `integer` (default: 50)

Results per page, from 1 to 200. A value above 200 is treated as 200.

**cursor** `string`

The `next_cursor` from the previous response. Omit it for the first page.

### Response fields

**data** `array`

The results on this page.

**next\_cursor** `string | null`

Pass this as `cursor` to get the next page. `null` on the last page.

**limit** `integer`

The page size the API applied.

```json Response theme={"dark"}
{
  "data": [
    { "id": "019a4f2e-8c1b-7d35-9e2a-4b6c1f0d3e57", "amount": 125000, "direction": "credit" }
  ],
  "next_cursor": "MjAyNi0xMS0wM1QxNDoyMjowNS4xMjM0NTZafDAxOWE0ZjJlLThjMWItN2QzNS05ZTJhLTRiNmMxZjBkM2U1Nw",
  "limit": 50
}
```

> [!WARNING]
>
> Treat cursors as opaque and pass them back unchanged. A cursor the API can't read returns the first page rather than an error, so a mangled cursor restarts your loop instead of failing. Stop when `next_cursor` is `null`.

### Fetch every page

This example lists every record in one data stream. `GET /records` needs at least one filter, here `data_stream_key`.

```bash cURL theme={"dark"}
cursor=""
while :; do
  response=$(curl -sG https://api.endclose.com/v1/records \
    -H "X-API-Key: $ENDCLOSE_API_KEY" \
    --data-urlencode "data_stream_key=operating_account" \
    --data-urlencode "limit=200" \
    ${cursor:+--data-urlencode "cursor=$cursor"})

  echo "$response" | jq -c '.data[]'

  cursor=$(echo "$response" | jq -r '.next_cursor // empty')
  [ -z "$cursor" ] && break
done
```

```python Python theme={"dark"}
import os
import requests

def list_records(data_stream_key):
    params = {"data_stream_key": data_stream_key, "limit": 200}
    headers = {"X-API-Key": os.environ["ENDCLOSE_API_KEY"]}

    while True:
        response = requests.get(
            "https://api.endclose.com/v1/records", params=params, headers=headers
        )
        response.raise_for_status()
        page = response.json()

        yield from page["data"]

        if page["next_cursor"] is None:
            break
        params["cursor"] = page["next_cursor"]

for record in list_records("operating_account"):
    print(record["id"], record["amount"])
```

## Offset pagination

A few endpoints page with `limit` and `offset` instead of a cursor:

| Endpoint | What it pages | Default `limit` | Maximum `limit` |
| - | - | - | - |
| `GET /reconciliation_matches` | Matches | 25 | 100 |
| `GET /reconciliation_exceptions` | Exceptions | 25 | 100 |
| `GET /file_imports/{id}/records` | Records from one file import | 25 | 100 |
| `GET /file_imports/{id}` | Row errors embedded in the file import | 50 | 200 |
| `GET /bulk_requests/{id}` | Row errors embedded in the bulk request | 50 | 200 |

`offset` defaults to 0. Each response carries `has_more` and an `offset` that is where the next page starts, so pass the returned `offset` back until `has_more` is `false`. `GET /reconciliation_matches` also returns `total_count`, the number of matches across all pages.

```json Response theme={"dark"}
{
  "data": [
    { "id": "019a4f31-02c7-7b9e-8a41-6d2e5c9f1a08", "reconciliation_id": "019a4e10-5b2d-7c80-b3f4-2a9d8e6c7b15" }
  ],
  "has_more": true,
  "offset": 25,
  "total_count": 73
}
```

On `GET /file_imports/{id}` and `GET /bulk_requests/{id}`, the paged list of row errors and its `has_more` and `offset` sit in a nested object rather than at the top level. Successful rows aren't listed there; they are records, which you can list with `GET /records?import_id=...`.

## Page-numbered review

`GET /reconciliation_exceptions/{id}/review` pages by number: `page` starts at 1 and `per_page` defaults to 50, up to 200. The response returns `page`, `per_page` and `total`, the number of rows matching your filters.

## Related

> [card] [End Close API](https://endclose.com/docs/api-reference/overview.md)
>
> Base URL, environments and conventions.

> [card] [List records](https://endclose.com/docs/api-reference/list-records.md)
>
> Filters and response fields for `GET /records`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.