# Pagination (https://docs.chargeflow.io/docs/reference/api-fundamentals/pagination)



All list endpoints in the Chargeflow API use page-based pagination via the `offset` and `limit` query parameters. `offset` is a zero-based page index, not an item count: increment it by 1 to move to the next page.

## Parameters [#parameters]

| Parameter | Type    | Default | Min | Max   | Description                         |
| --------- | ------- | ------- | --- | ----- | ----------------------------------- |
| `offset`  | integer | `0`     | `0` | -     | Zero-based page index to retrieve.  |
| `limit`   | integer | `25`    | `1` | `100` | Number of items to return per page. |

## Example request [#example-request]

```bash title="Terminal"
curl -X GET "https://api.chargeflow.io/public/2025-04-01/disputes?offset=0&limit=25" \
  -H "x-api-key: YOUR_API_KEY"
```

## Example response shape [#example-response-shape]

```json title="Response"
{
  "disputes": [{ "id": "66e6ea9ecd94925a9f8060d9" }, { "id": "66e6ea9ecd94925a9f8060da" }],
  "pagination": {
    "totalCount": 342,
    "offset": 0,
    "limit": 25,
    "totalPages": 14
  }
}
```

| Field                   | Description                                     |
| ----------------------- | ----------------------------------------------- |
| `disputes`              | Array of result objects for the current page.   |
| `pagination.totalCount` | Total number of items matching the query.       |
| `pagination.offset`     | The current zero-based page index.              |
| `pagination.limit`      | The number of items requested per page.         |
| `pagination.totalPages` | Total number of pages available for this query. |

## Paginating through all results [#paginating-through-all-results]

Increment `offset` by 1 per page and stop once you reach `pagination.totalPages`:

```javascript title="Node.js"
async function fetchAllDisputes(apiKey) {
  const baseUrl = 'https://api.chargeflow.io/public/2025-04-01/disputes';
  const limit = 100;
  let offset = 0;
  let allDisputes = [];

  while (true) {
    const response = await fetch(`${baseUrl}?offset=${offset}&limit=${limit}`, {
      headers: { 'x-api-key': apiKey },
    });
    const { disputes, pagination } = await response.json();

    allDisputes = allDisputes.concat(disputes);

    // Stop once the next page would be past the last one
    if (offset + 1 >= pagination.totalPages) break;
    offset += 1;
  }

  return allDisputes;
}
```

<Callout type="info">
  Set `limit=100` when fetching large datasets to minimize the number of requests needed to page
  through all results.
</Callout>

## Next steps [#next-steps]

<Cards>
  <Card title="Backfill 90 days of disputes" href="/docs/merchants/automation/backfill-90-days">
    A full pagination recipe.
  </Card>

  <Card title="Rate limits" href="/docs/reference/api-fundamentals/rate-limits">
    Pace your requests when paging large datasets.
  </Card>

  <Card title="API reference" href="/docs/api/2025-04-01/get-started">
    Every list endpoint and its parameters.
  </Card>
</Cards>
