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()
Function Name:
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()
Function Name:
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
Function Name:
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
Function Name:
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
Function Name:
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
Function Name:
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
Function Name:
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
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
Function Name:
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
Function Name:
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
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
Function Name:
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
Function Name:
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
Function Name:
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
Function Name:
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
Function Name:
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
Function Name:
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"
});