Links

Market Data

Documentation on interacting with a variety of OKX's Market Data API functions through the PENDAX Javascript SDK.
API calls for market data functions do not require account authentication/authorization.

Market Data

Get Tickers

This function is also included in "Common Functions" as getMarkets()
Please refer to the official OKX API Docs for required parameters.

Function Name:

getTickers()

Usage:

import { createExchange } from "./exchanges/exchange.js";
let myOkxAccount = createExchange({
exchange: "okx",
authenticate: true,
key: "myKeys",
secret: "mySecret",
passphrase: "myPassphrase",
label: "okx",
marginType: "usdt"
});
async function getTickers(exchange, options) {
try {
let result = await exchange.getTickers(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getTickers(myOkxAccount,
{
instType:"SWAP"
})

Get Ticker

This function is also included in "Common Functions" as getMarket()
Please refer to the official OKX API Docs for required parameters.

Function Name:

getTicker()

Usage:

import { createExchange } from "./exchanges/exchange.js";
let myOkxAccount = createExchange({
exchange: "okx",
authenticate: true,
key: "myKeys",
secret: "mySecret",
passphrase: "myPassphrase",
label: "okx",
marginType: "usdt"
});
async function getTicker(exchange, options) {
try {
let result = await exchange.getTicker(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getTicker(myOkxAccount,
{
instId: "BTC-USD-SWAP"
})

Get Index Tickers

Please refer to the official OKX API Docs for required parameters.

Function Name:

getIndexTickers()

Usage:

import { createExchange } from "./exchanges/exchange.js";
let myOkxAccount = createExchange({
exchange: "okx",
authenticate: true,
key: "myKeys",
secret: "mySecret",
passphrase: "myPassphrase",
label: "okx",
marginType: "usdt"
});
async function getIndexTickers(exchange, options) {
try {
let result = await exchange.getIndexTickers(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getIndexTickers(myOkxAccount,
{
instId: "BTC-USDT"
})

Get Order Book

Please refer to the official OKX API Docs for required parameters.

Function Name:

getOrderBook()

Usage:

import { createExchange } from "./exchanges/exchange.js";
let myOkxAccount = createExchange({
exchange: "okx",
authenticate: true,
key: "myKeys",
secret: "mySecret",
passphrase: "myPassphrase",
label: "okx",
marginType: "usdt"
});
async function getOrderBook(exchange, options) {
try {
let result = await exchange.getOrderBook(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getOrderBook(myOkxAccount,
{
instId: "BTC-USDT"
})

Get Candlesticks

Please refer to the official OKX API Docs for required parameters.

Function Name:

getCandles()

Usage:

import { createExchange } from "./exchanges/exchange.js";
let myOkxAccount = createExchange({
exchange: "okx",
authenticate: true,
key: "myKeys",
secret: "mySecret",
passphrase: "myPassphrase",
label: "okx",
marginType: "usdt"
});
async function getCandles(exchange, options) {
try {
let result = await exchange.getCandles(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getCandles(myOkxAccount,
{
instId: "BTC-USDT-SWAP"
})

Get Candlesticks History

Please refer to the official OKX API Docs for required parameters.

Function Name:

getCandleHistory()

Usage:

import { createExchange } from "./exchanges/exchange.js";
let myOkxAccount = createExchange({
exchange: "okx",
authenticate: true,
key: "myKeys",
secret: "mySecret",
passphrase: "myPassphrase",
label: "okx",
marginType: "usdt"
});
async function getCandleHistory(exchange, options) {
try {
let result = await exchange.getCandleHistory(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getCandleHistory(myOkxAccount,
{
instId: "BTC-USDT-SWAP"
})

Get Index Candlesticks

Please refer to the official OKX API Docs for required parameters.

Function Name:

getIndexCandles()

Usage:

import { createExchange } from "./exchanges/exchange.js";
let myOkxAccount = createExchange({
exchange: "okx",
authenticate: true,
key: "myKeys",
secret: "mySecret",
passphrase: "myPassphrase",
label: "okx",
marginType: "usdt"
});
async function getIndexCandles(exchange, options) {
try {
let result = await exchange.getIndexCandles(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getIndexCandles(myOkxAccount,
{
instId: "BTC-USD"
})

Get Mark Price Candlesticks

Please refer to the official OKX API Docs for required parameters.

Function Name:

getMarkPriceCandles()

Usage:

import { createExchange } from "./exchanges/exchange.js";
let myOkxAccount = createExchange({
exchange: "okx",
authenticate: true,
key: "myKeys",
secret: "mySecret",
passphrase: "myPassphrase",
label: "okx",
marginType: "usdt"
});
async function getMarkPriceCandles(exchange, options) {
try {
let result = await exchange.getMarkPriceCandles(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getMarkPriceCandles(myOkxAccount,
{
instId: "BTC-USD"
})

Get Trades

Please refer to the official OKX API Docs for required parameters.

Function Name:

getTrades()

Usage:

import { createExchange } from "./exchanges/exchange.js";
let myOkxAccount = createExchange({
exchange: "okx",
authenticate: true,
key: "myKeys",
secret: "mySecret",
passphrase: "myPassphrase",
label: "okx",
marginType: "usdt"
});
async function getTrades(exchange, options) {
try {
let result = await exchange.getTrades(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getTrades(myOkxAccount,
{
instId: "BTC-USD"
});

Get Trades History

Please refer to the official OKX API Docs for required parameters.

Function Name:

getTradesHistory()

Usage:

import { createExchange } from "./exchanges/exchange.js";
let myOkxAccount = createExchange({
exchange: "okx",
authenticate: true,
key: "myKeys",
secret: "mySecret",
passphrase: "myPassphrase",
label: "okx",
marginType: "usdt"
});
async function getTradesHistory(exchange, options) {
try {
let result = await exchange.getTradesHistory(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getTradesHistory(myOkxAccount,
{
instId: "BTC-USDT"
});

Get 24H Total Volume

Please refer to the official OKX API Docs for required parameters.

Function Name:

get24HrPlatformVolume()

Usage:

import { createExchange } from "./exchanges/exchange.js";
let myOkxAccount = createExchange({
exchange: "okx",
authenticate: true,
key: "myKeys",
secret: "mySecret",
passphrase: "myPassphrase",
label: "okx",
marginType: "usdt"
});
async function get24HrPlatformVolume(exchange, options) {
try {
let result = await exchange.get24HrPlatformVolume(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await get24HrPlatformVolume(myOkxAccount);

Get Oracle

Please refer to the official OKX API Docs for required parameters.

Function Name:

getOracle()

Usage:

import { createExchange } from "./exchanges/exchange.js";
let myOkxAccount = createExchange({
exchange: "okx",
authenticate: true,
key: "myKeys",
secret: "mySecret",
passphrase: "myPassphrase",
label: "okx",
marginType: "usdt"
});
async function getOracle(exchange, options) {
try {
let result = await exchange.getOracle(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getOracle(myOkxAccount);

Get Exchange Rate

Please refer to the official OKX API Docs for required parameters.

Function Name:

getExchangeRate()

Usage:

import { createExchange } from "./exchanges/exchange.js";
let myOkxAccount = createExchange({
exchange: "okx",
authenticate: true,
key: "myKeys",
secret: "mySecret",
passphrase: "myPassphrase",
label: "okx",
marginType: "usdt"
});
async function getExchangeRate(exchange, options) {
try {
let result = await exchange.getExchangeRate(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getExchangeRate(myOkxAccount);

Get Index Components

Please refer to the official OKX API Docs for required parameters.

Function Name:

getIndexComponents()

Usage:

import { createExchange } from "./exchanges/exchange.js";
let myOkxAccount = createExchange({
exchange: "okx",
authenticate: true,
key: "myKeys",
secret: "mySecret",
passphrase: "myPassphrase",
label: "okx",
marginType: "usdt"
});
async function getIndexComponents(exchange, options) {
try {
let result = await exchange.getIndexComponents(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getIndexComponents(myOkxAccount,
{
index: "BTC-USD"
});

Get Block Tickers

Please refer to the official OKX API Docs for required parameters.

Function Name:

getBlockTickers()

Usage:

import { createExchange } from "./exchanges/exchange.js";
let myOkxAccount = createExchange({
exchange: "okx",
authenticate: true,
key: "myKeys",
secret: "mySecret",
passphrase: "myPassphrase",
label: "okx",
marginType: "usdt"
});
async function getBlockTickers(exchange, options) {
try {
let result = await exchange.getBlockTickers(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getBlockTickers(myOkxAccount,
{
instType: "SWAP"
});

Get Block Ticker

Please refer to the official OKX API Docs for required parameters.

Function Name:

getBlockTicker()

Usage:

import { createExchange } from "./exchanges/exchange.js";
let myOkxAccount = createExchange({
exchange: "okx",
authenticate: true,
key: "myKeys",
secret: "mySecret",
passphrase: "myPassphrase",
label: "okx",
marginType: "usdt"
});
async function getBlockTicker(exchange, options) {
try {
let result = await exchange.getBlockTicker(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getBlockTicker(myOkxAccount,
{
instId: "BTC-USD-SWAP"
});

Get Block Trades

Please refer to the official OKX API Docs for required parameters.

Function Name:

getBlockTrades()

Usage:

import { createExchange } from "./exchanges/exchange.js";
let myOkxAccount = createExchange({
exchange: "okx",
authenticate: true,
key: "myKeys",
secret: "mySecret",
passphrase: "myPassphrase",
label: "okx",
marginType: "usdt"
});
async function getBlockTrades(exchange, options) {
try {
let result = await exchange.getBlockTrades(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getBlockTrades(myOkxAccount,
{
instId: "BTC-USDT"
});