> For the complete documentation index, see [llms.txt](https://docs-unified.crypto-chief.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs-unified.crypto-chief.com/getting-started/pagination-and-snapshots.md). Agents can also search and read this documentation through its [MCP server](https://docs-unified.crypto-chief.com/~gitbook/mcp).

# Pagination and Snapshots

## Pagination and Snapshots

Lists of transfers, transactions, UTXOs, NFTs, approvals, holders, events and assets come in pages:

```json
{
  "items": [],
  "next_cursor": "eyJ2IjoxLCJzIjoi…",
  "snapshot": [
    { "network": "ETH_MAINNET", "height": "23950112", "hash": "0x5c1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a", "indexed_through": "23950110" },
    { "network": "TRON_MAINNET", "height": "77120334", "hash": "000000000498b89e1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b9c8d9f1c", "indexed_through": null }
  ],
  "networks": [
    { "network": "ETH_MAINNET", "status": "ok", "source": "index", "consistency": "block", "as_of_block": { "height": "23950112", "hash": "0x5c1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a" } },
    { "network": "TRON_MAINNET", "status": "ok", "source": "native", "consistency": "block", "as_of_block": { "height": "77120334", "hash": "000000000498b89e1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d7e8f9a0b9c8d9f1c" } }
  ]
}
```

| Field         | Meaning                                                                                                                                    |
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| `items`       | This page                                                                                                                                  |
| `next_cursor` | Pass it as `cursor` to get the next page; `null` on the last page                                                                          |
| `snapshot`    | One entry per network: the block the whole pagination is pinned to                                                                         |
| `networks`    | Status of each network for this page — see [Partial Responses](https://docs-unified.crypto-chief.com/getting-started/partial-responses.md) |

Network lists, prices and the balances of an address are returned whole, as `{ "items": [...] }`, without a cursor.

### Page size

`limit` is `1`–`100`, `50` by default. [Event search](https://docs-unified.crypto-chief.com/api-reference/events.md) takes up to `1000` per page and returns `1000` by default.

### The snapshot

The **first page** pins every requested network to a block: `snapshot[].height` and `snapshot[].hash` are the head of that network when the first page was served. No page of that pagination returns an item above that height, so a page boundary cannot skip or repeat items while new blocks arrive. To see newer items, start a new pagination without a cursor.

`indexed_through` is the highest block covered by the network's history index at snapshot time, or `null` where history is read from the network directly. Blocks above it are read from the network for the same pagination: they are part of the result, not missing.

`stage` and `confirmations` of each item are computed when its page is served — see [Confirmations and Finality](https://docs-unified.crypto-chief.com/getting-started/confirmations-and-finality.md).

An empty page means the range was checked and nothing matched. A range the API cannot cover is an error, not an empty page: `422 HISTORY_OUT_OF_COVERAGE` or `503` ([Network Capabilities](https://docs-unified.crypto-chief.com/getting-started/network-capabilities.md)).

### The cursor

* It is opaque. Do not parse or build it.
* It belongs to the project, the filters, the order and the position reached on each network. Send it with **the same query parameters** as the first page; only `cursor` changes.
* It is valid for **24 hours**.

| Status | Code               | When                                                        | What to do                            |
| ------ | ------------------ | ----------------------------------------------------------- | ------------------------------------- |
| `400`  | `CURSOR_MISMATCH`  | The cursor was issued for different parameters              | Send the parameters of the first page |
| `410`  | `CURSOR_EXPIRED`   | The cursor is older than 24 hours                           | Start again without a cursor          |
| `409`  | `SNAPSHOT_REORGED` | A block of the snapshot is no longer on the canonical chain | See below                             |

#### `409 SNAPSHOT_REORGED`

```json
{
  "error": "SNAPSHOT_REORGED",
  "message": "Snapshot block was reorged; restart from safe_height.",
  "request_id": "req_01JDX9K8P2M4N6Q8R0T2V4W6Y8",
  "details": { "network": "ETH_MAINNET", "safe_height": "23950100" }
}
```

Items at or below `details.safe_height` on `details.network` are still valid. Drop what you received above it on that network and start a new pagination without a cursor; for a block range, set `from_block` to `safe_height`. Items on other networks are not affected.

### Order

`order` is `desc` (newest first, the default) or `asc`. [Event search](https://docs-unified.crypto-chief.com/api-reference/events.md) defaults to `asc`.

* **One network**: block height, then transaction index, then position inside the transaction, then `id`.
* **Several networks**: block time, then network code, then the single-network order.

### Ranges

Ranges are half-open: `[from, to)` and `[from_block, to_block)`. The lower bound is included, the upper is not.

* `from`, `to` — time, ISO 8601 or Unix seconds.
* `from_block`, `to_block` — block heights; only with a single network.

A block range longer than a network allows is `422 RANGE_TOO_LARGE` with `details.max`.

### Reading every page

{% tabs %}
{% tab title="JavaScript" %}

```javascript
// Every incoming transfer of an address on two networks.
async function* transfers(address, query) {
  let cursor;
  do {
    const { http, data } = await api("GET", `/addresses/${encodeURIComponent(address)}/transfers`, { ...query, cursor });
    if (http !== 200) throw new Error(`${http} ${data.error}: ${data.message}`);
    for (const n of data.networks ?? []) {
      if (n.status !== "ok") console.warn(n.network, n.status, n.error);
    }
    yield* data.items;
    cursor = data.next_cursor;
  } while (cursor);
}

for await (const t of transfers("0x1f33a8b5c6d7e8f90123456789abcdef012393c9", {
  networks: "ETH_MAINNET,BSC_MAINNET",
  direction: "in",
  limit: 100,
})) {
  console.log(t.network, t.id, t.amount.value, t.asset.symbol, t.stage);
}
```

{% endtab %}

{% tab title="Python" %}

```python
from urllib.parse import quote

def transfers(address, query):
    cursor = None
    while True:
        status, data, _ = api("GET", f"/addresses/{quote(address, safe='')}/transfers", {**query, "cursor": cursor})
        if status != 200:
            raise RuntimeError(f"{status} {data.get('error')}: {data.get('message')}")
        for n in data.get("networks", []):
            if n["status"] != "ok":
                print("warning:", n["network"], n["status"], n.get("error"))
        yield from data["items"]
        cursor = data["next_cursor"]
        if not cursor:
            return

for t in transfers("0x1f33a8b5c6d7e8f90123456789abcdef012393c9",
                   {"networks": "ETH_MAINNET,BSC_MAINNET", "direction": "in", "limit": 100}):
    print(t["network"], t["id"], t["amount"]["value"], t["asset"]["symbol"], t["stage"])
```

{% endtab %}
{% endtabs %}

A network whose status is not `ok` contributed no items to that page. Read that network again later; its items are identified by `(network, id)`, so reading them twice is harmless.
