Skip to main content
All methods in this section are public and do not require authentication. Instantiate the client without credentials:
import { RestClient } from 'okx-api';

const client = new RestClient();

Method reference

Tickers

MethodHTTPEndpointDescription
getTickers(params)GET/api/v5/market/tickersAll tickers for an instrument type
getTicker(params)GET/api/v5/market/tickerSingle instrument ticker
getIndexTickers(params?)GET/api/v5/market/index-tickersIndex tickers

Order books

MethodHTTPEndpointDescription
getOrderBook(params)GET/api/v5/market/booksOrder book (up to 400 levels)
getFullOrderBook(params)GET/api/v5/market/books-fullFull order book snapshot

Candles

MethodHTTPEndpointDescription
getCandles(params)GET/api/v5/market/candlesRecent candlestick data
getHistoricCandles(params)GET/api/v5/market/history-candlesHistorical candlestick data
getIndexCandles(params)GET/api/v5/market/index-candlesIndex price candles
getHistoricIndexCandles(params)GET/api/v5/market/history-index-candlesHistorical index candles
getMarkPriceCandles(params)GET/api/v5/market/mark-price-candlesMark price candles
getHistoricMarkPriceCandles(params)GET/api/v5/market/history-mark-price-candlesHistorical mark price candles

Trades

MethodHTTPEndpointDescription
getTrades(params)GET/api/v5/market/tradesRecent trades (up to 500)
getHistoricTrades(params)GET/api/v5/market/history-tradesHistorical trade data

Instruments and reference data

MethodHTTPEndpointDescription
getInstruments(params)GET/api/v5/public/instrumentsTradable instruments and their specs
getMarkPrice(params)GET/api/v5/public/mark-priceMark price for derivatives
getFundingRate(params)GET/api/v5/public/funding-rateCurrent funding rate for a SWAP
getFundingRateHistory(params)GET/api/v5/public/funding-rate-historyHistorical funding rates
getOpenInterest(params)GET/api/v5/public/open-interestOpen interest for derivatives
getOptionMarketData(params)GET/api/v5/public/opt-summaryOptions market summary data
getMinMaxLimitPrice(params)GET/api/v5/public/price-limitPrice band limits
getInsuranceFund(params)GET/api/v5/public/insurance-fundInsurance fund balance
getDeliveryExerciseHistory(params)GET/api/v5/public/delivery-exercise-historyDelivery and exercise history
getEstimatedDeliveryExercisePrice(params)GET/api/v5/public/estimated-priceEstimated settlement price
getDiscountRateAndInterestFreeQuota(params)GET/api/v5/public/discount-rate-interest-free-quotaDiscount rate tiers
getInterestRateAndLoanQuota()GET/api/v5/public/interest-rate-loan-quotaLoan quotas and interest rates
getUnitConvert(params)GET/api/v5/public/convert-contract-coinConvert between contract and coin units

System

MethodHTTPEndpointDescription
getSystemStatus(params)GET/api/v5/system/statusScheduled maintenance and system events
getSystemTime(params)GET/api/v5/public/timeServer timestamp
getServerTime()GET/api/v5/public/timeServer time as a number (ms)

Examples

Query instruments (no API keys needed)

import { RestClient } from 'okx-api';

const client = new RestClient();

// Get all SPOT instruments
const instruments = await client.getInstruments({ instType: 'SPOT' });
const sui = instruments.find((i) => i.baseCcy === 'SUI');
console.log('SUI-USDT min size:', sui?.minSz);
console.log('SUI-USDT tick size:', sui?.tickSz);

Get a ticker

const client = new RestClient();

// Single ticker
const [ticker] = await client.getTicker({ instId: 'BTC-USDT' });
console.log('Last price:', ticker.last);
console.log('24h volume:', ticker.vol24h);
console.log('Bid/Ask:', ticker.bidPx, '/', ticker.askPx);

// All SPOT tickers
const allTickers = await client.getTickers({ instType: 'SPOT' });
console.log('Total SPOT pairs:', allTickers.length);

Fetch candles

const client = new RestClient();

// Last 100 hourly candles for BTC-USDT
const candles = await client.getCandles({
  instId: 'BTC-USDT',
  bar: '1H',
  limit: '100',
});

// Each candle: [ts, open, high, low, close, vol, volCcy, volCcyQuote, confirm]
for (const [ts, open, high, low, close] of candles) {
  console.log(`${new Date(Number(ts)).toISOString()} O:${open} H:${high} L:${low} C:${close}`);
}

Get the order book

const client = new RestClient();

const [book] = await client.getOrderBook({
  instId: 'BTC-USDT',
  sz: '5',  // depth levels per side (max 400)
});

console.log('Best ask:', book.asks[0][0], 'qty:', book.asks[0][1]);
console.log('Best bid:', book.bids[0][0], 'qty:', book.bids[0][1]);

Get funding rate

const client = new RestClient();

const [rate] = await client.getFundingRate({ instId: 'BTC-USDT-SWAP' });
console.log('Current funding rate:', rate.fundingRate);
console.log('Next funding time:', new Date(Number(rate.nextFundingTime)));

// Funding rate history
const history = await client.getFundingRateHistory({
  instId: 'BTC-USDT-SWAP',
  limit: '10',
});
for (const h of history) {
  console.log(`${h.fundingTime}: ${h.fundingRate}`);
}

Check system status

const client = new RestClient();

const status = await client.getSystemStatus({});
for (const event of status) {
  console.log(`[${event.state}] ${event.title}`);
  console.log(`  Start: ${event.begin}, End: ${event.end}`);
}

Trading statistics

const client = new RestClient();

// Long/short ratio for BTC contracts
const ratio = await client.getLongShortRatio({
  ccy: 'BTC',
  period: '1H',
});
console.log('Long/short ratio:', ratio[0]);

// Taker buy/sell volume
const takerVol = await client.getTakerVolume({
  instType: 'SPOT',
  ccy: 'BTC',
  period: '1H',
});
console.log('Taker volume:', takerVol[0]);

Build docs developers (and LLMs) love