The API endpoints of Public Data
do not require authentication.
Public Data
Get Instruments
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 getInstruments(exchange, options) {
try {
let result = await exchange.getInstruments(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getInstruments(myOkxAccount,
{
instType: "SWAP"
});
Get Delivery/Exercise Data
Function Name:
getDeliveryAndRequestHistory()
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 getDeliveryAndRequestHistory(exchange, options) {
try {
let result = await exchange.getDeliveryAndRequestHistory(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getDeliveryAndRequestHistory(myOkxAccount,
{
instType: "OPTION",
uly: "BTC-USD"
});
Get Open Interest
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 getOpenInterest(exchange, options) {
try {
let result = await exchange.getOpenInterest(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getOpenInterest(myOkxAccount,
{
instType: "SWAP"
});
Get Funding 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 getFundingRate(exchange, options) {
try {
let result = await exchange.getFundingRate(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getFundingRate(myOkxAccount,
{
instId: "BTC-USD-SWAP"
});
Get Funding Rate 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 getFundingHistory(exchange, options) {
try {
let result = await exchange.getFundingHistory(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getFundingHistory(myOkxAccount,
{
instId: "BTC-USD-SWAP"
});
Get Limit Price
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 getLimitPrice(exchange, options) {
try {
let result = await exchange.getLimitPrice(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getLimitPrice(myOkxAccount,
{
instId: "BTC-USDT-SWAP"
});
Get Option Market Data
Function Name:
getOptionMarketData()
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 getOptionMarketData(exchange, options) {
try {
let result = await exchange.getOptionMarketData(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getOptionMarketData(myOkxAccount,
{
uly: "BTC-USD"
});
Get Estimated Delivery/Exercise Price
Function Name:
getEstimatedDelExpPrice()
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 getEstimatedDelExpPrice(exchange, options) {
try {
let result = await exchange.getEstimatedDelExpPrice(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getEstimatedDelExpPrice(myOkxAccount,
{
instId: "BTC-USD-230106-16200-P"
});
Get Discount Rate and Interest-Free Quota
Function Name:
getDiscRateAndIntFreeQuota()
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 getDiscRateAndIntFreeQuota(exchange, options) {
try {
let result = await exchange.getDiscRateAndIntFreeQuota(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getDiscRateAndIntFreeQuota(myOkxAccount,
{
instType: "SWAP"
});
Get System Time
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 getServerTime(exchange, options) {
try {
let result = await exchange.getServerTime(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getServerTime(myOkxAccount);
Get Liquidation Orders
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 getLiqOrders(exchange, options) {
try {
let result = await exchange.getLiqOrders(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getLiqOrders(myOkxAccount,
{
instType: "MARGIN",
instId: "BTC-USDT"
}));
Get Mark Price
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 getMarkPrice(exchange, options) {
try {
let result = await exchange.getMarkPrice(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getMarkPrice(myOkxAccount,
{
instType: "SWAP"
});
Get Position Tiers
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 getPositionTiers(exchange, options) {
try {
let result = await exchange.getPositionTiers(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getPositionTiers(myOkxAccount,
{
instType: "SWAP",
tdMode: "cross",
uly: ["BTC-USD"]
});
Get Interest Rate and Loan Quota
Function Name:
getInterestRateAndLoanQuota()
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 getInterestRateAndLoanQuota(exchange, options) {
try {
let result = await exchange.getInterestRateAndLoanQuota(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getInterestRateAndLoanQuota(myOkxAccount);
Get Interest Rate and Loan Quota for VIP Loans
Function Name:
getVipInterestRateAndLoanQuota()
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 getVipInterestRateAndLoanQuota(exchange, options) {
try {
let result = await exchange.getVipInterestRateAndLoanQuota(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getVipInterestRateAndLoanQuota(myOkxAccount);
Get Underlying
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 getUnderlying(exchange, options) {
try {
let result = await exchange.getUnderlying(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getUnderlying(myOkxAccount,
{
instType: "SWAP"
});
Get Insurance Fund
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 getInsuranceFund(exchange, options) {
try {
let result = await exchange.getInsuranceFund(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await getInsuranceFund(myOkxAccount,
{
instType: "SWAP",
uly: "BTC-USD"
});
Unit Convert
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 unitConvert(exchange, options) {
try {
let result = await exchange.unitConvert(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await unitConvert(myOkxAccount,
{
instId: "BTC-USD-SWAP",
px: "35000",
sz: "0.888"
});