Fetch OHLC candles for a perpetual market from a supported DEX (Gains Network, Lighter), normalized to a single shape regardless of upstream.
Documentation Index
Fetch the complete documentation index at: https://docs.mobula.io/llms.txt
Use this file to discover all available pages before exploring further.
GET /2/market/ohlcv-history and GET /2/token/ohlcv-history, so a single client can render both spot and perp charts.
dex + market (perp has no pool address).t. Duplicate timestamps and rows with h < l or non-finite values are dropped.data: [] with HTTP 200 is returned when the upstream has no data for the range.Note on Lighter: Only USD-quoted perps are supported (e.g.,BTC/USD,SOL/USD,HYPE/USD).
Note on Gains: Crypto, forex, stocks, and commodities are supported. Quote can be non-USD (e.g.,USD/JPY,EUR/CHF).
| Parameter | Type | Required | Description |
|---|---|---|---|
| dex | string | Yes | Upstream DEX to query. One of gains, lighter. |
| market | string | Yes | Pair in BASE/QUOTE format (e.g., BTC/USD, USD/JPY). Case-insensitive. |
| period | string | No | Candle width. One of 1m, 5m, 15m, 30m, 1h, 4h, 1d, 1w. Default 5m. |
| from | number | string | No | Range start (inclusive). UNIX seconds, UNIX milliseconds, or ISO date string. |
| to | number | string | No | Range end (inclusive). Same unit handling as from. Must be greater than from. |
| amount | number | No | Max candles to return (capped at 2000). When range yields more than amount, the most recent are kept. |
data is a candle:
| Field | Type | Description |
|---|---|---|
| t | number | UNIX seconds. |
| o | number | Opening price. |
| h | number | Highest price in the interval. |
| l | number | Lowest price in the interval. |
| c | number | Closing price. |
{t, o, h, l, c}). Perp has no v field — volume is not reported by the upstream DEXes.
BTC/USD, 1-minute candles for the last hour:USD/JPY, 5-minute candles, last 200 candles only:| Status | When | message |
|---|---|---|
| 400 | Zod validation failed (invalid dex, malformed market) | zod validation failed |
| 400 | from >= to | from must be < to |
| 400 | period not in supported set | unsupported period "<period>" |
| 404 | Market not found for the selected DEX (errors[0] lists example pairs) | unknown market "<market>" for dex "<dex>" |
| 502 | Upstream DEX returned an error (timeout, non-200, or code !== 200 for Lighter) | upstream <dex> error |
| 500 | Unexpected internal error | internal server error |
orderBookDetails) are fetched lazily on first request per process and cached for 5 minutes.traceId included in every log line for that request.Upstream DEX to query.
gains, lighter Human-readable pair in BASE/QUOTE format (e.g., BTC/USD, ETH/USD, USD/JPY). Case-insensitive — internally uppercased. Lighter only supports USD-quoted perps; Gains supports crypto, forex, stocks and commodities (quote may be non-USD).
Candle width.
1m, 5m, 15m, 30m, 1h, 4h, 1d, 1w Range start (inclusive). UNIX seconds, UNIX milliseconds, or ISO date string.
Range end (inclusive). Same unit handling as from. Must be greater than from.
Max number of candles to return (capped at 2000). When the range yields more candles than amount, only the most recent amount are returned.
Perp OHLCV history response. Candles sorted ascending by t. Duplicate timestamps and rows with h < l or non-finite values are dropped. Empty result sets are not errors — data: [] with HTTP 200 is returned when the upstream has no data for the range.