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

# Pagination

> Learn how to paginate through large result sets in the Breet API using page and size query parameters. Includes supported endpoints and response examples.

Endpoints that return lists of resources support pagination through query parameters. This allows you to retrieve data in manageable chunks rather than loading everything at once.

## Query parameters

| Parameter | Type    | Default | Description               |
| --------- | ------- | ------- | ------------------------- |
| `page`    | integer | `1`     | Page number (1-indexed).  |
| `size`    | integer | `10`    | Number of items per page. |

### Example request

```bash theme={null}
curl -X GET "https://api.breet.io/v1/trades/wallets?page=1&size=10" \
  -H "x-app-id: YOUR_APP_ID" \
  -H "x-app-secret: YOUR_APP_SECRET" \
  -H "X-Breet-Env: production"
```

## Paginated response

Every paginated endpoint returns a `meta` object alongside the `data` array. The `meta` object contains all the information you need to navigate through result pages:

```json theme={null}
{
  "success": true,
  "message": "wallets retrieved successfully",
  "data": [ ... ],
  "meta": {
    "pages": 2,
    "prevPage": null,
    "nextPage": 2,
    "page": 1,
    "totalDocs": 12,
    "hasPrevPage": false,
    "hasNextPage": true
  }
}
```

### Meta fields

| Field         | Type            | Description                                           |
| ------------- | --------------- | ----------------------------------------------------- |
| `pages`       | integer         | Total number of pages available.                      |
| `prevPage`    | integer or null | Previous page number, or `null` if on the first page. |
| `nextPage`    | integer or null | Next page number, or `null` if on the last page.      |
| `page`        | integer         | Current page number.                                  |
| `totalDocs`   | integer         | Total number of documents across all pages.           |
| `hasPrevPage` | boolean         | Whether a previous page exists.                       |
| `hasNextPage` | boolean         | Whether a next page exists.                           |

## Supported endpoints

The following endpoints support pagination:

| Endpoint                                                                 | Method | Description               |
| ------------------------------------------------------------------------ | ------ | ------------------------- |
| [`/trades/wallets`](/api-reference/crypto-wallet/fetch-wallet-addresses) | GET    | Fetch wallet addresses    |
| [`/trades/transactions`](/api-reference/transactions/fetch-transactions) | GET    | Fetch transactions        |
| [`/payments/integration-banks`](/api-reference/banks/fetch-saved-banks)  | GET    | Fetch saved bank accounts |
| [`/payments/withdrawals`](/api-reference/withdrawals/fetch-withdrawals)  | GET    | Fetch withdrawals         |

## Iterating through pages

To retrieve all results, start at `page=1` and keep requesting the next page until `hasNextPage` is `false`:

```javascript theme={null}
let page = 1;
let hasMore = true;

while (hasMore) {
  const response = await fetch(
    `https://api.breet.io/v1/trades/wallets?page=${page}&size=20`,
    { headers: { "x-app-id": APP_ID, "x-app-secret": APP_SECRET, "X-Breet-Env": "production" } }
  );
  const { data, meta } = await response.json();

  // Process data
  processWallets(data);

  hasMore = meta.hasNextPage;
  page = meta.nextPage;
}
```
