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

# Pagination

> Paginate DualEntry Public API list endpoints with limit and offset parameters, including defaults, maximums, and patterns for iterating large datasets.

List endpoints support limit/offset pagination to efficiently handle large datasets.

## Parameters

| Parameter | Type    | Default | Max | Description                                                 |
| --------- | ------- | ------- | --- | ----------------------------------------------------------- |
| `limit`   | integer | 100     | 100 | Number of records to return per page (1-100)                |
| `offset`  | integer | 0       | -   | Number of records to skip before starting to return results |

<Info>
  **Maximum Limit**: The `limit` parameter is capped at **100**. If you request more than 100 items, the API will return 100 items.
</Info>

## How it works

* **Page 1**: `offset=0, limit=100` → Returns records 1-100
* **Page 2**: `offset=100, limit=100` → Returns records 101-200
* **Page 3**: `offset=200, limit=100` → Returns records 201-300

## Example

```bash theme={null}
# First page (default)
curl "https://api.dualentry.com/public/v1/invoices" \
  -H "X-API-KEY: your_api_key_here"

# Custom page size
curl "https://api.dualentry.com/public/v1/invoices?limit=50&offset=100" \
  -H "X-API-KEY: your_api_key_here"
```

## Response format

List endpoints return an array of resources:

```json theme={null}
[
  {
    "id": "inv_001",
    "customer": "Customer A",
    "total": 1500.00
  },
  {
    "id": "inv_002",
    "customer": "Customer B",
    "total": 2300.00
  }
]
```

## Fetching all records

Continue fetching pages until you receive an empty array or fewer records than requested:

```python theme={null}
all_records = []
offset = 0
limit = 100

while True:
    response = requests.get(
        "https://api.dualentry.com/public/v1/invoices",
        headers=headers,
        params={"limit": limit, "offset": offset}
    )
    
    records = response.json()
    if not records:
        break
    
    all_records.extend(records)
    
    if len(records) < limit:
        break
    
    offset += limit
```

<Info>
  **Best Practice**: When fetching all records, add delays between requests to respect rate limits.
</Info>

## Validation errors

Invalid pagination parameters will return a `400 Bad Request` error:

| Invalid Request | Error Message                              |
| --------------- | ------------------------------------------ |
| `limit=0`       | Input should be greater than or equal to 1 |
| `limit=-1`      | Input should be greater than or equal to 1 |
| `offset=-1`     | Input should be greater than or equal to 0 |

**Note:** Requesting `limit > 100` will not return an error. The limit will be silently capped at 100.

**Example error response:**

```json theme={null}
{
  "success": false,
  "errors": {
    "__all__": ["greater_than_equal query.limit: Input should be greater than or equal to 1"]
  }
}
```

***

**Next:** [Learn about Errors →](./errors)
