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

# Paginating Through DexUtils API List Endpoint Results

> DexUtils API uses page-based pagination. Use limit and page query parameters to navigate large result sets for pools and transactions.

List endpoints across the DexUtils API — including pools, transactions, and search — return paginated responses to keep payload sizes manageable and response times fast. You control how many results appear per page and which page you want using the `limit` and `page` query parameters. Every paginated response includes metadata at the top level so you always know how far through the full dataset you are.

## Query Parameters

Append `limit` and `page` to any list endpoint URL to navigate result sets. Both parameters are optional; the API falls back to sensible defaults if you omit them.

| Parameter | Default | Maximum | Applies To         |
| --------- | ------- | ------- | ------------------ |
| `limit`   | 20      | 100     | Pools, Search      |
| `limit`   | 50      | 200     | Transactions       |
| `page`    | 1       | —       | All list endpoints |

## Response Metadata

Every paginated response wraps the results array alongside three top-level metadata fields. Use these fields to determine whether more pages exist and to build progress indicators.

| Field   | Type    | Description                                 |
| ------- | ------- | ------------------------------------------- |
| `total` | integer | Total number of records matching your query |
| `page`  | integer | The current page number                     |
| `limit` | integer | The number of results returned on this page |

A typical paginated response looks like this:

```json Pool List Response theme={null}
{
  "total": 4821,
  "page": 1,
  "limit": 100,
  "pools": [
    { "address": "0xabc...", "dex": "uniswap_v3", "liquidity": 2450000 }
  ]
}
```

## Paginating Through Pools

The example below fetches every pool on Ethereum by walking forward through pages until the accumulated count meets the `total` returned by the API.

<CodeGroup>
  ```python paginate_pools.py theme={null}
  import requests

  API_KEY = "YOUR_API_KEY"
  BASE_URL = "https://api.dexutils.io/v1"

  headers = {"Authorization": f"Bearer {API_KEY}"}
  url = f"{BASE_URL}/networks/ethereum/pools"

  page = 1
  all_pools = []

  while True:
      response = requests.get(url, headers=headers, params={"limit": 100, "page": page})
      response.raise_for_status()
      data = response.json()
      all_pools.extend(data["pools"])

      if len(all_pools) >= data["total"]:
          break
      page += 1

  print(f"Fetched {len(all_pools)} pools")
  ```

  ```javascript paginate_pools.js theme={null}
  const API_KEY = "YOUR_API_KEY";
  const BASE_URL = "https://api.dexutils.io/v1";

  async function getAllPools() {
    const headers = { Authorization: `Bearer ${API_KEY}` };
    const baseUrl = `${BASE_URL}/networks/ethereum/pools`;

    let page = 1;
    let allPools = [];

    while (true) {
      const response = await fetch(`${baseUrl}?limit=100&page=${page}`, { headers });
      if (!response.ok) throw new Error(`HTTP ${response.status}`);
      const data = await response.json();
      allPools = allPools.concat(data.pools);

      if (allPools.length >= data.total) break;
      page++;
    }

    return allPools;
  }
  ```
</CodeGroup>

<Tip>
  Always pass `sort` and `order` parameters alongside `limit` and `page` to guarantee deterministic ordering across pages. Without a stable sort, records can shift between pages as new data is indexed, causing duplicates or gaps in your results.
</Tip>

## Paginating Through Transactions

Transactions endpoints support a higher maximum `limit` of 200 per page, which is useful when iterating through high-volume pools.

<CodeGroup>
  ```python paginate_txns.py theme={null}
  import requests

  API_KEY = "YOUR_API_KEY"
  BASE_URL = "https://api.dexutils.io/v1"

  def get_all_transactions(network, pool_address):
      headers = {"Authorization": f"Bearer {API_KEY}"}
      url = f"{BASE_URL}/networks/{network}/pools/{pool_address}/transactions"

      page = 1
      all_txns = []

      while True:
          response = requests.get(url, headers=headers, params={"limit": 200, "page": page})
          response.raise_for_status()
          data = response.json()
          all_txns.extend(data["transactions"])

          if len(all_txns) >= data["total"]:
              break
          page += 1

      return all_txns
  ```

  ```javascript paginate_txns.js theme={null}
  const API_KEY = "YOUR_API_KEY";
  const BASE_URL = "https://api.dexutils.io/v1";

  async function getAllTransactions(network, poolAddress) {
    const headers = { Authorization: `Bearer ${API_KEY}` };
    const baseUrl = `${BASE_URL}/networks/${network}/pools/${poolAddress}/transactions`;

    let page = 1;
    let allTxns = [];

    while (true) {
      const response = await fetch(`${baseUrl}?limit=200&page=${page}`, { headers });
      if (!response.ok) throw new Error(`HTTP ${response.status}`);
      const data = await response.json();
      allTxns = allTxns.concat(data.transactions);

      if (allTxns.length >= data.total) break;
      page++;
    }

    return allTxns;
  }
  ```
</CodeGroup>

<Note>
  For large transaction datasets, using `from_timestamp` and `to_timestamp` query parameters is significantly more efficient than page-based iteration. Time-range queries allow the API to use indexed scans rather than offset-based lookups, reducing both latency and quota consumption on your end.
</Note>
