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

# Pagination & Filtering

> How to paginate through results, filter data, sort responses, and set currency across Zerion API endpoints.

Most Zerion API list endpoints return paginated results and support filtering. This page covers the patterns you'll use across the API.

## Pagination

List endpoints use **cursor-based pagination**. Each response includes a `links` object with URLs for navigating between pages.

### How it works

1. Make your initial request without any page parameter
2. Check `links.next` in the response — if present, there are more results
3. Follow the `links.next` URL directly to get the next page
4. Repeat until `links.next` is absent

```json Response with pagination theme={null}
{
  "links": {
    "self": "https://api.zerion.io/v1/wallets/0x.../positions/?page[size]=10",
    "next": "https://api.zerion.io/v1/wallets/0x.../positions/?page[size]=10&page[after]=eyJhZnR..."
  },
  "data": [...]
}
```

Control the number of results per page with `page[size]`:

| Parameter    | Type    | Default | Min | Max   |
| ------------ | ------- | ------- | --- | ----- |
| `page[size]` | integer | `100`   | `1` | `100` |

<Warning>
  Do not construct `page[after]` cursor values manually. Always use the full URL from `links.next` — cursor tokens are opaque and may change format without notice.
</Warning>

### Iterating through all pages

<CodeGroup>
  ```javascript JavaScript theme={null}
  async function fetchAll(url, apiKey) {
    const results = [];

    while (url) {
      const response = await fetch(url, {
        headers: { Authorization: `Basic ${btoa(`${apiKey}:`)}` }
      });
      const json = await response.json();
      results.push(...json.data);
      url = json.links.next || null;
    }

    return results;
  }

  const positions = await fetchAll(
    "https://api.zerion.io/v1/wallets/0x.../positions/?page[size]=100",
    "YOUR_API_KEY"
  );
  ```

  ```python Python theme={null}
  import requests

  def fetch_all(url, api_key):
      results = []

      while url:
          response = requests.get(url, auth=(api_key, ""))
          data = response.json()
          results.extend(data["data"])
          url = data["links"].get("next")

      return results

  positions = fetch_all(
      "https://api.zerion.io/v1/wallets/0x.../positions/?page[size]=100",
      "YOUR_API_KEY"
  )
  ```
</CodeGroup>

## Filtering

Filter parameters use the `filter[field]` syntax. Pass multiple values as comma-separated:

```
?filter[chain_ids]=ethereum,base&filter[position_types]=deposit,staked
```

Common filters include `chain_ids`, `position_types`, `operation_types`, `trash`, `search_query`, and `fungible_ids`. Each endpoint documents its available filters and accepted values in the relevant API reference page, such as [wallet positions](/api-reference/wallets/get-wallet-fungible-positions), [wallet transactions](/api-reference/wallets/get-wallet-transactions), or [fungibles search](/api-reference/fungibles/get-list-of-fungible-assets). For spam filtering behavior, see the [spam filtering guide](/spam-filtering).

## Sorting

Some endpoints support a `sort` parameter. Prefix with `-` for descending order:

```
?sort=-value
```

Available sort fields vary by endpoint — check the relevant list endpoint in the API reference, such as [wallet positions](/api-reference/wallets/get-wallet-fungible-positions) or [wallet transactions](/api-reference/wallets/get-wallet-transactions), for supported options.

## Currency

Most endpoints that return monetary values accept a `currency` parameter. Default is `usd`.

```
?currency=eur
```

Supports major fiat currencies and `eth`/`btc`. See any currency-aware endpoint, such as [wallet positions](/api-reference/wallets/get-wallet-fungible-positions), for the full list.
