# OKX Crypto Market Data API

> OKX spot, swap and futures market data: tickers, order book depth and OHLC candles

- Vendor: `okxcryptomarketdataapi` · version 1.0 · category Crypto Market Data · tags okx api, crypto ticker api, crypto order book api, bitcoin price api, crypto candles api, exchange data api
- Datasource: custom HTTP routes
- Marketplace page: https://apiclay.com/api/okxcryptomarketdataapi
- This document: https://apiclay.com/docs/okxcryptomarketdataapi.md
- OpenAPI 3.1: https://apiclay.com/api/okxcryptomarketdataapi/openapi.json
- MCP: connect https://api.apiclay.com/v1/mcp (see https://apiclay.com/llms.txt), then `apiclay_describe_api` with vendor `okxcryptomarketdataapi`
- Updated: 2026-11-18

## About

## OKX Crypto Market Data API

Public market data from the OKX exchange: the last price, 24h open/high/low and volume for one instrument or every instrument of a type (spot, perpetual swaps, futures, options), the live order book, and OHLC candles from 1-minute to 1-month bars.

Data comes from **okx.com** (https://www.okx.com). Every route calls the source's own public API and returns it unchanged.

Typical flow: `/tickers?instType=SPOT` to list instruments, then `/ticker?instId=BTC-USDT`, `/orderbook?instId=BTC-USDT&amp;sz=20` and `/candles?instId=BTC-USDT&amp;bar=1H&amp;limit=100`.

### Routes

#### GET `/ticker` - Ticker
| Param | In | Type | Required | Description |
|---|---|---|---|---|
| instId | query | string | yes | Instrument, e.g. `BTC-USDT`, `ETH-USDT-SWAP`. |

Returns: `data[]` with `last`, `askPx`, `bidPx`, `open24h`, `high24h`, `low24h`, `vol24h`, `volCcy24h`, `ts`.

#### GET `/tickers` - All tickers
| Param | In | Type | Required | Description |
|---|---|---|---|---|
| instType | query | string | yes | `SPOT`, `SWAP`, `FUTURES` or `OPTION`. |
| instFamily | query | string | no | e.g. `BTC-USD` for derivatives. |

Returns: `data[]` of tickers with the same fields.

#### GET `/orderbook` - Order book
| Param | In | Type | Required | Description |
|---|---|---|---|---|
| instId | query | string | yes | Instrument. |
| sz | query | number | no | Depth per side (max 400). |

Returns: `data[0].asks` / `bids` as `[price, size, 0, orders]`, `ts`.

#### GET `/candles` - Candles
| Param | In | Type | Required | Description |
|---|---|---|---|---|
| instId | query | string | yes | Instrument. |
| bar | query | string | no | `1m`, `5m`, `15m`, `1H`, `4H`, `1D`, `1W`, `1M`... |
| limit | query | number | no | Candles (max 300). |
| after | query | string | no | Page back: candles before this ms timestamp. |
| before | query | string | no | Candles after this ms timestamp. |

Returns: `data[]` rows `[ts, open, high, low, close, vol, volCcy, volCcyQuote, confirm]`, newest first.

### Caveats

- Exchange market data; check OKX's terms before commercial redistribution. OKX is not available in every country.
- Upstream responses can change over time. Verify fields before relying on them.
- Not affiliated with or endorsed by okx.com.

## Pricing

- Pay as you go: 0.0012 credits/request
- Trial: 1 free requests per buyer
- Billing order: trial requests -> subscribed plan requests -> pay as you go. 1 credit's USD value is shown on the marketplace page.

## HTTP routes

Only the public, buyer-facing parts of each route are listed; vendor-side credentials stay on the gateway.

### GET /ticker — Ticker
- Gateway: `GET https://api.apiclay.com/v1/api/okxcryptomarketdataapi/ticker`
- Public query params: `instId` (string, required)
- Upstream proxy: ApiClay proxy paid by the vendor (data cap 2 MB per call). Fetched through an ApiClay proxy paid by the vendor; a response larger than the route's data cap fails with 502 and is refunded in full.

### GET /tickers — All tickers
- Gateway: `GET https://api.apiclay.com/v1/api/okxcryptomarketdataapi/tickers`
- Public query params: `instType` (string, required), `instFamily` (string)
- Upstream proxy: ApiClay proxy paid by the vendor (data cap 2 MB per call). Fetched through an ApiClay proxy paid by the vendor; a response larger than the route's data cap fails with 502 and is refunded in full.

### GET /orderbook — Order book
- Gateway: `GET https://api.apiclay.com/v1/api/okxcryptomarketdataapi/orderbook`
- Public query params: `instId` (string, required), `sz` (number)
- Upstream proxy: ApiClay proxy paid by the vendor (data cap 2 MB per call). Fetched through an ApiClay proxy paid by the vendor; a response larger than the route's data cap fails with 502 and is refunded in full.

### GET /candles — Candles
- Gateway: `GET https://api.apiclay.com/v1/api/okxcryptomarketdataapi/candles`
- Public query params: `instId` (string, required), `bar` (string), `limit` (number), `after` (string), `before` (string)
- Upstream proxy: ApiClay proxy paid by the vendor (data cap 2 MB per call). Fetched through an ApiClay proxy paid by the vendor; a response larger than the route's data cap fails with 502 and is refunded in full.

## Call example

```bash
curl -X GET "https://api.apiclay.com/v1/api/okxcryptomarketdataapi/ticker?instId=<instId>" \
  -H "token: <YOUR_APICLAY_TOKEN>"
```

Index of every published API: https://apiclay.com/llms.txt
