OKX v5 public market data: candles with archive fallback, order books, funding, open interest and the rubik analytics series.
bookspassing, 0.4scandlespassing, 0.1sfunding-rate-historypassing, 0.1sfunding-ratepassing, 0.1shistory-candlespassing, 0.1sinstrumentspassing, 0.1slong-short-ratiopassing, 0.1smark-pricepassing, 0.1sopen-interest-volumepassing, 0.3sopen-interestpassing, 0.1sprice-limitpassing, 0.1staker-volumepassing, 0.3stickerpassing, 0.1stickerspassing, 0.1stradespassing, 0.1s/v1/finance:okx/booksno cache2 paramschecking key…// npm i zpi-sdk
import { ZpiClient } from "zpi-sdk";
const client = new ZpiClient({ apiKey: "zpi_xxxxxxxxxxxxxxxxxxxxxxxx" });
const data = await client.run("finance:okx", "books", {
"symbol": "BTC-USDT-SWAP",
"count": 20
});
console.log(data);curl -X GET "https://api.zpi.web.id/v1/finance:okx/books?symbol=BTC-USDT-SWAP&count=20" \
-H "x-api-key: zpi_xxxxxxxxxxxxxxxxxxxxxxxx"/v1/finance:okx/booksOrder-book snapshot for one OKX instrument.symbolstringrequiredcountnumberoptionalcurl -X GET "https://api.zpi.web.id/v1/finance:okx/books?symbol=BTC-USDT-SWAP&count=20" \
-H "x-api-key: zpi_xxxxxxxxxxxxxxxxxxxxxxxx"{
"asks": [
{
"size": 116.79,
"price": 71647.1,
"orderCount": 15
},
{
"size": 0.01,
"price": 71647.4,
"orderCount": 1
},
{
"size": 0.01,
"price": 71647.7,
"orderCount": 1
},
{
"size": 0.02,
"price": 71647.8,
"orderCount": 1
},
{
"size": 0.32,
"price": 71647.9,
"orderCount": 2
},
{
"size": 27.64,
"price": 71648,
"orderCount": 10
}
],
"bids": [
{
"size": 245.55,
"price": 71647,
"orderCount": 24
},
{
"size": 0.01,
"price": 71645.3,
"orderCount": 1
},
{
"size": 0.01,
"price": 71645,
"orderCount": 1
},
{
"size": 2.8,
"price": 71644.9,
"orderCount": 2
},
{
"size": 66.24,
"price": 71644.8,
"orderCount": 4
},
{
"size": 17.47,
"price": 71644.7,
"orderCount": 2
}
],
"date": "2026-08-20T14:57:49.556Z",
"time": 1787237869556,
"symbol": "BTC-USDT-SWAP",
"dataset": "books",
"askCount": 20,
"bidCount": 20,
"provider": "okx",
"sequence": 334874037257
}/v1/finance:okx/candlesOHLCV candles for one OKX instrument, with the live-window trap guarded.symbolstringrequiredbarenumoptionalendstringoptionalcountnumberoptionalpagenumberoptionalcurl -X GET "https://api.zpi.web.id/v1/finance:okx/candles?symbol=BTC-USDT-SWAP&bar=5m&end=2026-08-14T00%3A00%3A00Z&count=100&page=1" \
-H "x-api-key: zpi_xxxxxxxxxxxxxxxxxxxxxxxx"{
"bar": "5m",
"page": 1,
"count": 100,
"items": [
{
"low": 63660.1,
"date": "2026-08-13T15:40:00.000Z",
"high": 63731.3,
"open": 63678.2,
"close": 63695.1,
"volume": 14417.99,
"isClosed": true,
"openTime": 1786635600000,
"closeTime": 1786635899999,
"volumeQuote": 9183713.97058,
"volumeCurrency": 144.1799
},
{
"low": 63594.3,
"date": "2026-08-13T15:45:00.000Z",
"high": 63695.2,
"open": 63695.1,
"close": 63602.4,
"volume": 19226.23,
"isClosed": true,
"openTime": 1786635900000,
"closeTime": 1786636199999,
"volumeQuote": 12234135.96111,
"volumeCurrency": 192.2623
},
{
"low": 63558.4,
"date": "2026-08-13T15:50:00.000Z",
"high": 63658.8,
"open": 63602.4,
"close": 63589.9,
"volume": 26785.7,
"isClosed": true,
"openTime": 1786636200000,
"closeTime": 1786636499999,
"volumeQuote": 17034946.38627,
"volumeCurrency": 267.857
}
],
"symbol": "BTC-USDT-SWAP",
"dataset": "candles",
"hasMore": true,
"nextPage": 2,
"provider": "okx",
"fromArchive": true
}/v1/finance:okx/funding-rate-historySettled funding for one OKX perpetual.symbolstringrequiredendstringoptionalcountnumberoptionalpagenumberoptionalcurl -X GET "https://api.zpi.web.id/v1/finance:okx/funding-rate-history?symbol=BTC-USDT-SWAP&end=2026-08-01T00%3A00%3A00Z&count=100&page=1" \
-H "x-api-key: zpi_xxxxxxxxxxxxxxxxxxxxxxxx"{
"page": 1,
"count": 100,
"items": [
{
"date": "2026-06-28T16:00:00.000Z",
"time": 1782662400000,
"method": "current_period",
"symbol": "BTC-USDT-SWAP",
"formulaType": "withRate",
"fundingRate": 0.0000395436281002,
"realizedRate": 0.0000395436281002
},
{
"date": "2026-06-29T00:00:00.000Z",
"time": 1782691200000,
"method": "current_period",
"symbol": "BTC-USDT-SWAP",
"formulaType": "withRate",
"fundingRate": 0.0000046598340778,
"realizedRate": 0.0000046598340778
},
{
"date": "2026-06-29T08:00:00.000Z",
"time": 1782720000000,
"method": "current_period",
"symbol": "BTC-USDT-SWAP",
"formulaType": "withRate",
"fundingRate": 0.0000503634854124,
"realizedRate": 0.0000503634854124
}
],
"symbol": "BTC-USDT-SWAP",
"dataset": "funding-rate-history",
"hasMore": true,
"nextPage": 2,
"provider": "okx"
}/v1/finance:okx/funding-rateCurrent and next funding for one OKX perpetual, with the rate caps.symbolstringrequiredcurl -X GET "https://api.zpi.web.id/v1/finance:okx/funding-rate?symbol=BTC-USDT-SWAP" \
-H "x-api-key: zpi_xxxxxxxxxxxxxxxxxxxxxxxx"{
"date": "2026-08-20T14:58:05.180Z",
"time": 1787237885180,
"method": "current_period",
"symbol": "BTC-USDT-SWAP",
"dataset": "funding-rate",
"premium": -0.0005606459980755,
"instType": "SWAP",
"provider": "okx",
"formulaType": "withRate",
"fundingDate": "2026-08-20T16:00:00.000Z",
"fundingRate": 0.0000694968722686,
"fundingTime": 1787241600000,
"impactValue": 20000,
"interestRate": 0.0001,
"maxFundingRate": 0.00375,
"minFundingRate": -0.00375,
"nextFundingDate": "2026-08-21T00:00:00.000Z",
"nextFundingRate": null,
"nextFundingTime": 1787270400000,
"settlementState": "settled",
"settledFundingRate": 0.0001,
"previousFundingDate": "2026-08-20T08:00:00.000Z",
"previousFundingTime": 1787212800000
}/v1/finance:okx/history-candlesThe OKX candle ARCHIVE — the real backfill, 300 bars per call.symbolstringrequiredbarenumoptionalendstringoptionalcountnumberoptionalpagenumberoptionalcurl -X GET "https://api.zpi.web.id/v1/finance:okx/history-candles?symbol=BTC-USDT-SWAP&bar=5m&end=2020-06-01T00%3A00%3A00Z&count=100&page=1" \
-H "x-api-key: zpi_xxxxxxxxxxxxxxxxxxxxxxxx"{
"bar": "5m",
"page": 1,
"count": 100,
"items": [
{
"low": 9463,
"date": "2020-05-31T15:40:00.000Z",
"high": 9481.1,
"open": 9477,
"close": 9463.2,
"volume": 10297,
"isClosed": true,
"openTime": 1590939600000,
"closeTime": 1590939899999,
"volumeQuote": 975559.58625,
"volumeCurrency": 102.97
},
{
"low": 9455.4,
"date": "2020-05-31T15:45:00.000Z",
"high": 9472.8,
"open": 9463.1,
"close": 9461.4,
"volume": 9213,
"isClosed": true,
"openTime": 1590939900000,
"closeTime": 1590940199999,
"volumeQuote": 871856.6235,
"volumeCurrency": 92.13
},
{
"low": 9450.1,
"date": "2020-05-31T15:50:00.000Z",
"high": 9478.3,
"open": 9461.3,
"close": 9476.7,
"volume": 11532,
"isClosed": true,
"openTime": 1590940200000,
"closeTime": 1590940499999,
"volumeQuote": 1091236.57275,
"volumeCurrency": 115.32
}
],
"symbol": "BTC-USDT-SWAP",
"dataset": "history-candles",
"hasMore": true,
"nextPage": 2,
"provider": "okx"
}/v1/finance:okx/instrumentsContract specifications for one OKX product line: tick, lot, leverage, expiry.instTypeenumoptionalsymbolstringoptionalinstFamilystringoptionalulystringoptionalcurl -X GET "https://api.zpi.web.id/v1/finance:okx/instruments?instType=SWAP&symbol=BTC-USDT-SWAP&instFamily=BTC-USDT&uly=BTC-USD" \
-H "x-api-key: zpi_xxxxxxxxxxxxxxxxxxxxxxxx"{
"count": 1,
"items": [
{
"alias": null,
"state": "live",
"symbol": "BTC-USDT-SWAP",
"lotSize": 0.01,
"minSize": 0.01,
"instType": "SWAP",
"listDate": "2019-11-12T11:16:48.000Z",
"listTime": 1573557408000,
"ruleType": "normal",
"tickSize": 0.1,
"expiryDate": null,
"expiryTime": null,
"instFamily": "BTC-USDT",
"optionType": null,
"maxLeverage": 100,
"strikePrice": null,
"baseCurrency": null,
"contractType": "linear",
"maxLimitSize": 100000000,
"contractValue": 0.01,
"maxMarketSize": 35000,
"quoteCurrency": null,
"maxLimitAmount": 20000000,
"settleCurrency": "USDT",
"contractMultiplier": 1,
"contractValueCurrency": "BTC"
}
],
"symbol": "BTC-USDT-SWAP",
"dataset": "instruments",
"instType": "SWAP",
"provider": "okx"
}/v1/finance:okx/long-short-ratioLong/short account ratio across an OKX coin.currencystringoptionalperiodenumoptionalstartstringoptionalendstringoptionalcurl -X GET "https://api.zpi.web.id/v1/finance:okx/long-short-ratio?currency=BTC&period=5m&start=2026-08-19T00%3A00%3A00Z&end=2026-08-20T00%3A00%3A00Z" \
-H "x-api-key: zpi_xxxxxxxxxxxxxxxxxxxxxxxx"{
"count": 289,
"items": [
{
"date": "2026-08-19T00:00:00.000Z",
"time": 1787097600000,
"longShortRatio": 1.38
},
{
"date": "2026-08-19T00:05:00.000Z",
"time": 1787097900000,
"longShortRatio": 1.38
},
{
"date": "2026-08-19T00:10:00.000Z",
"time": 1787098200000,
"longShortRatio": 1.38
},
{
"date": "2026-08-19T00:15:00.000Z",
"time": 1787098500000,
"longShortRatio": 1.35
},
{
"date": "2026-08-19T00:20:00.000Z",
"time": 1787098800000,
"longShortRatio": 1.36
},
{
"date": "2026-08-19T00:25:00.000Z",
"time": 1787099100000,
"longShortRatio": 1.36
}
],
"period": "5m",
"dataset": "long-short-ratio",
"currency": "BTC",
"provider": "okx"
}/v1/finance:okx/mark-priceMark price for OKX derivatives, one instrument or a whole product line.instTypeenumoptionalsymbolstringoptionalinstFamilystringoptionalcurl -X GET "https://api.zpi.web.id/v1/finance:okx/mark-price?instType=SWAP&symbol=BTC-USDT-SWAP&instFamily=BTC-USDT" \
-H "x-api-key: zpi_xxxxxxxxxxxxxxxxxxxxxxxx"{
"count": 1,
"items": [
{
"date": "2026-08-20T14:58:34.087Z",
"time": 1787237914087,
"symbol": "BTC-USDT-SWAP",
"instType": "SWAP",
"markPrice": 71637.9
}
],
"symbol": "BTC-USDT-SWAP",
"dataset": "mark-price",
"instType": "SWAP",
"provider": "okx"
}/v1/finance:okx/open-interest-volumeOpen interest and trading volume across an OKX coin, as a series.currencystringoptionalperiodenumoptionalstartstringoptionalendstringoptionalcurl -X GET "https://api.zpi.web.id/v1/finance:okx/open-interest-volume?currency=BTC&period=5m&start=2026-08-19T00%3A00%3A00Z&end=2026-08-20T00%3A00%3A00Z" \
-H "x-api-key: zpi_xxxxxxxxxxxxxxxxxxxxxxxx"{
"count": 289,
"items": [
{
"date": "2026-08-19T00:00:00.000Z",
"time": 1787097600000,
"volume": 4625681.3003,
"openInterest": 2734863303.818
},
{
"date": "2026-08-19T00:05:00.000Z",
"time": 1787097900000,
"volume": 19376638.5103,
"openInterest": 2732066244.4829
},
{
"date": "2026-08-19T00:10:00.000Z",
"time": 1787098200000,
"volume": 21160767.9023,
"openInterest": 2736080690.2392
},
{
"date": "2026-08-19T00:15:00.000Z",
"time": 1787098500000,
"volume": 18460955.7031,
"openInterest": 2735382416.5911
},
{
"date": "2026-08-19T00:20:00.000Z",
"time": 1787098800000,
"volume": 17187939.4254,
"openInterest": 2735341157.5042
},
{
"date": "2026-08-19T00:25:00.000Z",
"time": 1787099100000,
"volume": 8980848.8529,
"openInterest": 2734355299.2411
}
],
"period": "5m",
"dataset": "open-interest-volume",
"currency": "BTC",
"provider": "okx"
}/v1/finance:okx/open-interestOpen interest for OKX derivatives — a live snapshot, not a series.instTypeenumoptionalsymbolstringoptionalinstFamilystringoptionalcurl -X GET "https://api.zpi.web.id/v1/finance:okx/open-interest?instType=SWAP&symbol=BTC-USDT-SWAP&instFamily=BTC-USDT" \
-H "x-api-key: zpi_xxxxxxxxxxxxxxxxxxxxxxxx"{
"count": 1,
"items": [
{
"date": "2026-08-20T14:58:47.103Z",
"time": 1787237927103,
"symbol": "BTC-USDT-SWAP",
"instType": "SWAP",
"openInterest": 3014259.4000000125,
"openInterestUsd": 2159463662.310409,
"openInterestBase": 30142.59400000013
}
],
"symbol": "BTC-USDT-SWAP",
"dataset": "open-interest",
"instType": "SWAP",
"provider": "okx"
}/v1/finance:okx/price-limitThe band OKX will accept orders inside for one instrument, right now.symbolstringrequiredcurl -X GET "https://api.zpi.web.id/v1/finance:okx/price-limit?symbol=BTC-USDT-SWAP" \
-H "x-api-key: zpi_xxxxxxxxxxxxxxxxxxxxxxxx"{
"date": "2026-08-20T14:58:53.307Z",
"time": 1787237933307,
"symbol": "BTC-USDT-SWAP",
"dataset": "price-limit",
"enabled": true,
"buyLimit": 72046,
"instType": "SWAP",
"provider": "okx",
"sellLimit": 71328.7
}/v1/finance:okx/taker-volumeTaker buy and sell volume across an OKX coin.currencystringoptionalinstTypeenumoptionalperiodenumoptionalstartstringoptionalendstringoptionalcurl -X GET "https://api.zpi.web.id/v1/finance:okx/taker-volume?currency=BTC&instType=CONTRACTS&period=5m&start=2026-08-19T00%3A00%3A00Z&end=2026-08-20T00%3A00%3A00Z" \
-H "x-api-key: zpi_xxxxxxxxxxxxxxxxxxxxxxxx"{
"count": 289,
"items": [
{
"date": "2026-08-19T00:00:00.000Z",
"time": 1787097600000,
"buyVolume": 1157482.2695,
"sellVolume": 3468199.0308
},
{
"date": "2026-08-19T00:05:00.000Z",
"time": 1787097900000,
"buyVolume": 4028628.1914,
"sellVolume": 15347874.6106
},
{
"date": "2026-08-19T00:10:00.000Z",
"time": 1787098200000,
"buyVolume": 4554562.4544,
"sellVolume": 16606205.4479
},
{
"date": "2026-08-19T00:15:00.000Z",
"time": 1787098500000,
"buyVolume": 2839560.0399,
"sellVolume": 15621395.6632
},
{
"date": "2026-08-19T00:20:00.000Z",
"time": 1787098800000,
"buyVolume": 5391706.8318,
"sellVolume": 11793019.5104
},
{
"date": "2026-08-19T00:25:00.000Z",
"time": 1787099100000,
"buyVolume": 5629821.6608,
"sellVolume": 3351027.1921
}
],
"period": "5m",
"dataset": "taker-volume",
"currency": "BTC",
"provider": "okx"
}/v1/finance:okx/tickerLive 24h snapshot for one OKX instrument.symbolstringrequiredcurl -X GET "https://api.zpi.web.id/v1/finance:okx/ticker?symbol=BTC-USDT-SWAP" \
-H "x-api-key: zpi_xxxxxxxxxxxxxxxxxxxxxxxx"{
"date": "2026-08-20T14:59:12.768Z",
"time": 1787237952768,
"low24h": 65856.4,
"symbol": "BTC-USDT-SWAP",
"askSize": 64.45,
"bidSize": 1072.36,
"dataset": "ticker",
"high24h": 72492.9,
"open24h": 65894.6,
"askPrice": 71728,
"bidPrice": 71727.9,
"instType": "SWAP",
"lastSize": 0.09,
"openUtc0": 69307.9,
"openUtc8": 68530,
"provider": "okx",
"lastPrice": 71727.9,
"volume24h": 22525952.7,
"volumeCurrency24h": 225259.527
}/v1/finance:okx/tickersLive 24h snapshot for every OKX instrument in one product line.instTypeenumoptionalinstFamilystringoptionalulystringoptionalcurl -X GET "https://api.zpi.web.id/v1/finance:okx/tickers?instType=SWAP&instFamily=BTC-USDT&uly=BTC-USD" \
-H "x-api-key: zpi_xxxxxxxxxxxxxxxxxxxxxxxx"{
"count": 1,
"items": [
{
"date": "2026-08-20T14:59:22.766Z",
"time": 1787237962766,
"low24h": 65856.4,
"symbol": "BTC-USDT-SWAP",
"askSize": 194.64,
"bidSize": 419.76,
"high24h": 72492.9,
"open24h": 65894.6,
"askPrice": 71740.2,
"bidPrice": 71740.1,
"instType": "SWAP",
"lastSize": 0.6,
"openUtc0": 69307.9,
"openUtc8": 68530,
"lastPrice": 71740.2,
"volume24h": 22527583.84,
"volumeCurrency24h": 225275.8384
}
],
"dataset": "tickers",
"instType": "SWAP",
"provider": "okx"
}/v1/finance:okx/tradesRecent public prints for one OKX instrument, newest first.symbolstringrequiredcountnumberoptionalcurl -X GET "https://api.zpi.web.id/v1/finance:okx/trades?symbol=BTC-USDT-SWAP&count=100" \
-H "x-api-key: zpi_xxxxxxxxxxxxxxxxxxxxxxxx"{
"count": 100,
"items": [
{
"date": "2026-08-20T14:59:27.499Z",
"side": "sell",
"size": 0.04,
"time": 1787237967499,
"price": 71745,
"symbol": "BTC-USDT-SWAP",
"tradeId": "2846741966"
},
{
"date": "2026-08-20T14:59:27.145Z",
"side": "sell",
"size": 0.07,
"time": 1787237967145,
"price": 71745,
"symbol": "BTC-USDT-SWAP",
"tradeId": "2846741965"
},
{
"date": "2026-08-20T14:59:27.127Z",
"side": "sell",
"size": 2.59,
"time": 1787237967127,
"price": 71745,
"symbol": "BTC-USDT-SWAP",
"tradeId": "2846741964"
},
{
"date": "2026-08-20T14:59:26.979Z",
"side": "buy",
"size": 3.29,
"time": 1787237966979,
"price": 71745.1,
"symbol": "BTC-USDT-SWAP",
"tradeId": "2846741963"
},
{
"date": "2026-08-20T14:59:26.963Z",
"side": "buy",
"size": 0.03,
"time": 1787237966963,
"price": 71745.1,
"symbol": "BTC-USDT-SWAP",
"tradeId": "2846741962"
},
{
"date": "2026-08-20T14:59:26.963Z",
"side": "buy",
"size": 0.01,
"time": 1787237966963,
"price": 71745.1,
"symbol": "BTC-USDT-SWAP",
"tradeId": "2846741961"
}
],
"symbol": "BTC-USDT-SWAP",
"dataset": "trades",
"provider": "okx"
}