All Funding & Account API endpoints require authentication. Please create OKX API keys to interact with these functions successfully.
Funding
Get Currencies
Function Name:
fundingGetCurrencies()
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 fundingGetCurrencies(exchange, options) {
try {
let result = await exchange.fundingGetCurrencies(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await fundingGetCurrencies(myOkxAccount)
Get Balance
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 fundingGetBalance(exchange, options) {
try {
let result = await exchange.fundingGetBalance(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await fundingGetBalance(myOkxAccount)
Get Account Asset Valuation
Function Name:
fundingGetAssetValuation()
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 fundingGetAssetValuation(exchange, options) {
try {
let result = await exchange.fundingGetAssetValuation(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await fundingGetAssetValuation(myOkxAccount)
Funds Transfer
Function Name:
fundingAssetTransfer()
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 fundingAssetTransfer(exchange, options) {
try {
let result = await exchange.fundingAssetTransfer(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await fundingAssetTransfer(myOkxAccount,
{
ccy:"USDT",
amt:"1.5",
from:"6",
to:"18"
})
Get Funds Transfer State
Function Name:
fundingGetFundsTransferState()
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 fundingGetFundsTransferState(exchange, options) {
try {
let result = await exchange.fundingGetFundsTransferState(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await fundingGetFundsTransferState(myOkxAccount,
{
transId: "1",
type: "1"
})
Asset Bill Details
Function Name:
fundingGetAssetBillsDetails()
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 fundingGetAssetBillsDetails(exchange, options) {
try {
let result = await exchange.fundingGetAssetBillsDetails(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await fundingGetAssetBillsDetails(myOkxAccount)
Get Deposit Address
Function Name:
fundingGetDepositAddress()
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 fundingGetDepositAddress(exchange, options) {
try {
let result = await exchange.fundingGetDepositAddress(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await fundingGetDepositAddress(myOkxAccount,
{
ccy: "BTC"
})
Get Deposit History
Function Name:
fundingGetDepositHistory()
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 fundingGetDepositHistory(exchange, options) {
try {
let result = await exchange.fundingGetDepositHistory(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await fundingGetDepositHistory(myOkxAccount)
Withdrawal
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 fundingWithdrawal(exchange, options) {
try {
let result = await exchange.fundingWithdrawal(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await fundingWithdrawal(myOkxAccount,
{
amt:"1",
fee:"0.0005",
dest:"4",
ccy:"BTC",
chain:"BTC-Bitcoin",
toAddr:"17DKe3kkkkiiiiTvAKKi2vMPbm1Bz3CMKw"
})
Get Withdrawal History
Function Name:
fundingGetWithdrawalHistory()
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 fundingGetWithdrawalHistory(exchange, options) {
try {
let result = await exchange.fundingGetWithdrawalHistory(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await fundingGetWithdrawalHistory(myOkxAccount)
Small Assets 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 fundingConvertDust(exchange, options) {
try {
let result = await exchange.fundingConvertDust(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await fundingConvertDust(myOkxAccount,
{
ccy:["BTC","USDT"]
})
Get Saving Balance
Function Name:
fundingGetSavingBalance()
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 fundingGetSavingBalance(exchange, options) {
try {
let result = await exchange.fundingGetSavingBalance(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await fundingGetSavingBalance(myOkxAccount)
Savings Purchase/Redemption
Function Name:
fundingSavingsAndPurchaseRedemption()
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 fundingSavingsAndPurchaseRedemption(exchange, options) {
try {
let result = await exchange.fundingSavingsAndPurchaseRedemption(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await fundingSavingsAndPurchaseRedemption(myOkxAccount,
{
ccy:"BTC",
amt:"1",
side:"purchase",
rate:"0.01"
}
)
Set Lending Rate
Function Name:
fundingSetLendingRate()
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 fundingSetLendingRate(exchange, options) {
try {
let result = await exchange.fundingSetLendingRate(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await fundingSetLendingRate(myOkxAccount,
{
ccy:"BTC",
rate:"0.02"
}
)
Get Lending History
Function Name:
fundingGetLendingHistory()
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 fundingGetLendingHistory(exchange, options) {
try {
let result = await exchange.fundingGetLendingHistory(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await fundingGetLendingHistory(myOkxAccount)
Get Public Borrow Info
Function Name:
fundingGetPublicBorrowInfo()
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 fundingGetPublicBorrowInfo(exchange, options) {
try {
let result = await exchange.fundingGetPublicBorrowInfo(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await fundingGetPublicBorrowInfo(myOkxAccount)
Get Public Borrow History
Function Name:
fundingGetPublicBorrowHistory()
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 fundingGetPublicBorrowHistory(exchange, options) {
try {
let result = await exchange.fundingGetPublicBorrowHistory(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await fundingGetPublicBorrowHistory(myOkxAccount)
Lightning Deposits
Function Name:
fundingLightningDeposit()
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 fundingLightningDeposit(exchange, options) {
try {
let result = await exchange.fundingLightningDeposit(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await fundingLightningDeposit(myOkxAccount,
{
ccy: "BTC",
amt: "0.1"
}
)
Lightning Withdrawals
Function Name:
fundingLightningWithdrawal()
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 fundingLightningWithdrawal(exchange, options) {
try {
let result = await exchange.fundingLightningWithdrawal(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await fundingLightningWithdrawal(myOkxAccount,
{
ccy:"BTC",
invoice:"lnbc100u1psnnvhtpp5yq2x3q5hhrzsuxpwx7ptphwzc4k4wk0j3stp0099968m44cyjg9sdqqcqzpgxqzjcsp5hz"
}
)
Cancel Withdrawal
Function Name:
fundingCancelWithdrawal()
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 fundingCancelWithdrawal(exchange, options) {
try {
let result = await exchange.fundingCancelWithdrawal(options);
console.log(result);
} catch (error) {
console.log(error.message);
}
}
const result = await fundingCancelWithdrawal(myOkxAccount,
{
wdId:"1123456"
}
)