# OKX Exchange API
> Live market data from OKX, one of the largest crypto exchanges, across both spot and perpetual markets, served straight from its public v5 API — no key, nothing cached. The ticker endpoint returns any instrument's snapshot — last price, best bid and ask, 24-hour open/high/low, volume and the 24-hour percentage change — for a spot pair like BTC-USDT or a perpetual swap like BTC-USDT-SWAP. The tickers endpoint returns every instrument of a type (spot, swap or futures) in one call, sortable by 24-hour change or volume. The candles endpoint returns OHLC candles at a bar you choose, from one minute to one month. The funding endpoint returns the funding rate of any perpetual swap — the periodic payment between longs and shorts — with the rate annualised to an APR and the next funding time, the signal perpetual-futures traders watch. Everything is OKX's live venue data, nothing stored. This is the OKX price, perpetual-funding and candle layer for any trading, charting, derivatives or market-data app. Distinct from Coinbase, Bitstamp, Binance and Kraken venue APIs and from aggregated feeds — this is OKX's own spot and perpetual order flow and its per-contract funding rates. 4 endpoints, no key on our side, real-time.

## Authentication
All requests require your oanor API key in the `x-oanor-key` header. Get one at https://www.oanor.com/developer/keys.

```bash
curl -H "x-oanor-key: oanor_live_…" "https://api.oanor.com/okx-api/..."
```

## Pricing
- **Free** (Free) — 6,000 calls/Mo, 5 req/s
- **Starter** ($13/Mo) — 135,000 calls/Mo, 12 req/s
- **Pro** ($33/Mo) — 820,000 calls/Mo, 30 req/s
- **Mega** ($82/Mo) — 4,400,000 calls/Mo, 80 req/s

## Endpoints

### OKX

#### `GET /v1/candles` — OHLC candles

**Parameters:**
- `inst` (query, required, string) — Instrument id Example: `ETH-USDT`
- `bar` (query, optional, string) — 1m,5m,15m,1H,4H,1D,1W,1M (default 1H) Example: `1H`
- `limit` (query, optional, string) — Max candles (1-300) Example: `50`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/okx-api/v1/candles?inst=ETH-USDT&bar=1H&limit=50"
```

**Response:**
```json
{
    "data": {
        "bar": "1H",
        "inst": "ETH-USDT",
        "count": 50,
        "source": "OKX",
        "candles": [
            {
                "iso": "2026-06-09T20:00:00.000Z",
                "low": 1655.65,
                "high": 1663.98,
                "open": 1657.48,
                "time": 1781035200000,
                "close": 1656.21,
                "volume": 2280.158764
            },
            {
                "iso": "2026-06-09T19:00:00.000Z",
                "low": 1646.79,
                "high": 1658.68,
                "open": 1652.28,
                "time": 1781031600000,
                "close": 1657.47,
                "volume": 5388.015143
            },
            {
                "iso": "2026-06-09T18:00:00.000Z",
                "low": 1640,
                "high": 1655.7,
                "open": 1643.04,
                "time": 1781028000000,
                "close": 1652.28,
                "volume": 4506.621654
            },
            {
                "iso": "2026-06-09T17:00:00.000Z",
                "low": 1632.25,
                "high": 1650,
                "open": 1632.29,
                "time": 1781024400000,
                "close": 1642.93,
                "volume": 6823.332069
            },
            {
                "iso": "2026-06-09T16:00:00.000Z",
                "low": 1614.19,
                "high": 1639.52,
                "open": 1636.35,
                "time": 1781020800000,
                "
…(truncated, see openapi.json for full schema)
```

#### `GET /v1/funding` — Perpetual funding rate + APR

**Parameters:**
- `inst` (query, required, string) — Perp instrument (or spot pair, -SWAP added) Example: `BTC-USDT-SWAP`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/okx-api/v1/funding?inst=BTC-USDT-SWAP"
```

**Response:**
```json
{
    "data": {
        "inst": "BTC-USDT-SWAP",
        "note": "funding paid every 8 hours; APR = rate x 3 x 365",
        "type": "SWAP",
        "source": "OKX",
        "funding_rate": 2.73005677008e-5,
        "funding_time": "2026-06-10T00:00:00.000Z",
        "funding_apr_pct": 2.9894,
        "funding_rate_pct": 0.00273,
        "next_funding_rate": null,
        "next_funding_time": "2026-06-10T08:00:00.000Z"
    },
    "meta": {
        "timestamp": "2026-06-09T20:24:47.832Z",
        "request_id": "f2758386-5b38-4c85-87b7-dc4978bdceaf"
    },
    "status": "ok",
    "message": "Funding rate retrieved successfully",
    "success": true
}
```

#### `GET /v1/ticker` — An instrument ticker

**Parameters:**
- `inst` (query, required, string) — Instrument id (BTC-USDT or BTC-USDT-SWAP) Example: `BTC-USDT`

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/okx-api/v1/ticker?inst=BTC-USDT"
```

**Response:**
```json
{
    "data": {
        "ask": 62013.6,
        "bid": 62013.5,
        "inst": "BTC-USDT",
        "last": 62013.5,
        "time": "2026-06-09T20:24:47.075Z",
        "type": "SPOT",
        "source": "OKX",
        "low_24h": 60770,
        "high_24h": 63854.4,
        "open_24h": 63279.4,
        "volume_24h": 32542.07581913,
        "change_24h_pct": -2.0005,
        "volume_24h_ccy": 2009716251.9101443
    },
    "meta": {
        "timestamp": "2026-06-09T20:24:48.134Z",
        "request_id": "d0340831-4e41-4f23-bf7d-2d9a88f2f19a"
    },
    "status": "ok",
    "message": "Ticker retrieved successfully",
    "success": true
}
```

#### `GET /v1/tickers` — All instruments of a type

**Parameters:**
- `type` (query, optional, string) — SPOT (default), SWAP or FUTURES Example: `SWAP`
- `sort` (query, optional, string) — change or volume Example: `change`
- `limit` (query, optional, string) — Max rows

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/okx-api/v1/tickers?type=SWAP&sort=change"
```

**Response:**
```json
{
    "data": {
        "sort": "change",
        "count": 364,
        "source": "OKX",
        "tickers": [
            {
                "ask": 0.03435,
                "bid": 0.03433,
                "inst": "HOME-USDT-SWAP",
                "last": 0.03433,
                "time": "2026-06-09T20:24:48.097Z",
                "type": "SWAP",
                "low_24h": 0.02461,
                "high_24h": 0.03676,
                "open_24h": 0.02847,
                "volume_24h": 9380001,
                "change_24h_pct": 20.5831,
                "volume_24h_ccy": 938000100
            },
            {
                "ask": 0.01664,
                "bid": 0.01663,
                "inst": "SENT-USDT-SWAP",
                "last": 0.01662,
                "time": "2026-06-09T20:24:48.096Z",
                "type": "SWAP",
                "low_24h": 0.01344,
                "high_24h": 0.01781,
                "open_24h": 0.01382,
                "volume_24h": 26470485,
                "change_24h_pct": 20.2605,
                "volume_24h_ccy": 2647048500
            },
            {
                "ask": 1.6499,
                "bid": 1.6498,
                "inst": "LIT-USDT-SWAP",
                "last": 1.6498,
                "time": "2026-06-09T20:24:48.085Z",
                "type": "SWAP",
                "low_24h": 1.4506,
                "high_24h": 1.687,
                "open_24h": 1.4569,
                "volume_24h": 26899999,
                "change_24h_pct":
…(truncated, see openapi.json for full schema)
```

### Meta

#### `GET /v1/meta` — Spec

**Example:**
```bash
curl -H "x-oanor-key: $KEY" \
  "https://api.oanor.com/okx-api/v1/meta"
```

**Response:**
```json
{
    "data": {
        "source": "OKX public API v5 (live)",
        "service": "okx-api",
        "endpoints": {
            "GET /v1/meta": "This document.",
            "GET /v1/ticker": "An instrument's ticker (inst=BTC-USDT or BTC-USDT-SWAP).",
            "GET /v1/candles": "OHLC candles (inst=BTC-USDT, bar=1m..1M).",
            "GET /v1/funding": "Perpetual funding rate + APR (inst=BTC-USDT-SWAP or BTC-USDT).",
            "GET /v1/tickers": "All instruments of a type (type=SPOT|SWAP|FUTURES, sort=change|volume)."
        },
        "description": "Live market data from OKX across spot and perpetual markets, from its public v5 API: any instrument's ticker (last, bid/ask, 24h open/high/low, volume, 24h % change) for a spot pair or a perpetual swap; every instrument of a type (spot, swap, futures) in one call, sortable; OHLC candles at a chosen bar (1m to 1M); and the funding rate of any perpetual swap with the rate annualised to an APR and the next funding time. Live, no key, nothing stored. Distinct from Coinbase, Bitstamp, Binance and Kraken venue APIs and from aggregated feeds — this is OKX's own spot and perpetual order flow and its per-contract funding rates.",
        "upstream_status": "ok"
    },
    "meta": {
        "timestamp": "2026-06-09T20:24:48.820Z",
        "request_id": "2c0124dc-9ba2-4c47-bb68-093d3b1fd989"
    },
    "status": "ok",
    "message": "Meta",
    "success": true
}
```


---
Marketplace page: https://www.oanor.com/api/okx-api
OpenAPI spec: https://www.oanor.com/api/okx-api/openapi.json
