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

# CCXT Hyperliquid historical candles

> Fetch Hyperliquid OHLCV in CCXT past the 5,000-candle limit: point fetch_ohlcv at your Ironflow key and page through your plan's history.

Hyperliquid's API only returns about the last 5,000 candles per interval, so CCXT's `fetch_ohlcv` stops at about 3.5 days of `1m`. Point CCXT at your Ironflow key and it reaches your plan's full history.

Tested with CCXT 4.5.92.

```python ironflow_ccxt.py theme={null}
import os
import ccxt

ex = ccxt.hyperliquid()
ex.load_markets()                     # markets come from Hyperliquid's own API
ex.urls["api"]["public"] = f"https://api.ironflow.sh/rpc/{os.environ['IRONFLOW_KEY']}"
ex.rateLimit = 250                    # one candle call a second fits a free key


def history(symbol, timeframe, days):
    """Up to `days` of candles, older than now, oldest first."""
    step = ex.parse_timeframe(timeframe) * 1000
    end = ex.milliseconds() // step * step
    stop = end - days * 86_400_000
    candles = {}
    while end > stop:
        since = max(stop, end - 1000 * step)
        page = ex.fetch_ohlcv(symbol, timeframe, since=since, params={"until": end})
        if not page:
            break
        candles.update({c[0]: c for c in page})
        end = page[0][0]
    return [candles[t] for t in sorted(candles)]


rows = history("BTC/USDC:USDC", "1m", days=7)
print(len(rows), rows[0], rows[-1])
```

```bash theme={null}
pip install ccxt
IRONFLOW_KEY=if_your_key python ironflow_ccxt.py
```

Seven days of `1m` is 10,080 candles, past Hyperliquid's limit.

## How it works

The [Hyperliquid RPC](https://docs.ironflow.sh/guides/hyperliquid-rpc.md) answers `candleSnapshot`, CCXT's candle call, in Hyperliquid's own shape. It returns at most the latest 1,000 candles per call, so `history` walks back with `until`.

Set the URL **after** `load_markets()`: loading markets uses `metaAndAssetCtxs` and `spotMetaAndAssetCtxs`, which the RPC does not serve.

Use this client for candles only. Tickers and funding use types the RPC refuses, and it never serves orders. Keep a second, plain `ccxt.hyperliquid()` for those.

Timeframes from `1m` to `3d`. Always pass `since` (a missing one answers `400`).

## Plan limits

| Plan | Candle history | Requests |
| - | - | - |
| Free key | 14 days | 60 a minute |
| Explorer | 90 days | 100 a minute |
| Builder | 1 year | 1,000 a minute |
| Enterprise | Everything stored | 10,000 a minute |

A free key's 14 days is 20,160 `1m` candles. Hourly it is 336, less than Hyperliquid's own 5,000; for long hourly history use Builder or the [free datasets](https://docs.ironflow.sh/guides/datasets.md). The RPC has no keyless access: [get a free key](https://ironflow.sh/key).

Candles are built from every fill, so high, low and trade count can differ from Hyperliquid's own candles in heavy liquidation hours.

Next: [paper trade on Hyperliquid](https://ironflow.sh/guides/hyperliquid-paper-trading) with the official SDK, \$10,000 and live prices.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.