Public Data
Documentation on interacting with a variety of OKX's Public Data API functions through the PENDAX Javascript SDK.
The API endpoints of Public Data
do not require authentication.
Public Data
Get Instruments
Please refer to the official OKX API Docs for the required parameters.
https://www.okx.com/docs-v5/en/#rest-api-public-data-get-instruments
Function Name:
getInstruments()
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
Please refer to the official OKX API Docs for required parameters.
https://www.okx.com/docs-v5/en/#rest-api-public-data-get-delivery-exercise-history
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
Please refer to the official OKX API Docs for required parameters.
https://www.okx.com/docs-v5/en/#rest-api-public-data-get-open-interest
Function Name:
getOpenInterest()
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
Please refer to the official OKX API Docs for required parameters.
https://www.okx.com/docs-v5/en/#rest-api-public-data-get-funding-rate
Function Name:
getFundingRate()
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
Please refer to the official OKX API Docs for required parameters.
https://www.okx.com/docs-v5/en/#rest-api-public-data-get-funding-rate-history
Function Name:
getFundingHistory()
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
Please refer to the official OKX API Docs for required parameters.
https://www.okx.com/docs-v5/en/#rest-api-public-data-get-limit-price
Function Name:
getLimitPrice()
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
Please refer to the official OKX API Docs for required parameters.
https://www.okx.com/docs-v5/en/#rest-api-public-data-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
Please refer to the official OKX API Docs for required parameters.
https://www.okx.com/docs-v5/en/#rest-api-public-data-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
Please refer to the official OKX API Docs for required parameters.
https://www.okx.com/docs-v5/en/#rest-api-public-data-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
Please refer to the official OKX API Docs for required parameters.
https://www.okx.com/docs-v5/en/#rest-api-public-data-get-system-time
Function Name:
getServerTime()
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
Please refer to the official OKX API Docs for required parameters.
https://www.okx.com/docs-v5/en/#rest-api-public-data-get-liquidation-orders
Function Name:
getLiqOrders()
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
Please refer to the official OKX API Docs for required parameters.
https://www.okx.com/docs-v5/en/#rest-api-public-data-get-mark-price
Function Name:
getMarkPrice()
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
Please refer to the official OKX API Docs for required parameters.
https://www.okx.com/docs-v5/en/#rest-api-public-data-get-position-tiers
Function Name:
getPositionTiers()
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
Please refer to the official OKX API Docs for required parameters.
https://www.okx.com/docs-v5/en/#rest-api-public-data-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
Please refer to the official OKX API Docs for required parameters.
https://www.okx.com/docs-v5/en/#rest-api-public-data-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
Please refer to the official OKX API Docs for required parameters.
https://www.okx.com/docs-v5/en/#rest-api-public-data-get-underlying
Function Name:
getUnderlying()
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
Please refer to the official OKX API Docs for required parameters.
https://www.okx.com/docs-v5/en/#rest-api-public-data-get-insurance-fund
Function Name:
getInsuranceFund()
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
Please refer to the official OKX API Docs for required parameters.
https://www.okx.com/docs-v5/en/#rest-api-public-data-unit-convert
Function Name:
unitConvert()
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"
});
Last updated