Skip to main content
All funding methods require authentication unless noted otherwise.

Method reference

Balances and currencies

MethodHTTPEndpointDescription
getCurrencies(params?)GET/api/v5/asset/currenciesSupported currencies and chain info
getBalances(params?)GET/api/v5/asset/balancesFunding account balances
getAccountAssetValuation(params?)GET/api/v5/asset/asset-valuationTotal asset valuation in a given currency
getNonTradableAssets(params?)GET/api/v5/asset/non-tradable-assetsNon-tradable asset balances

Transfers

MethodHTTPEndpointDescription
fundsTransfer(params)POST/api/v5/asset/transferTransfer between funding and trading accounts
getFundsTransferState(params?)GET/api/v5/asset/transfer-stateStatus of a previous transfer
getAssetBillsDetails(params?)GET/api/v5/asset/billsFunding account bills (last month)

Deposits

MethodHTTPEndpointDescription
getDepositAddress(params)GET/api/v5/asset/deposit-addressOn-chain deposit address for a currency
getDepositHistory(params?)GET/api/v5/asset/deposit-historyDeposit history
getLightningDeposits(params)GET/api/v5/asset/deposit-lightningGenerate a Lightning Network invoice

Withdrawals

MethodHTTPEndpointDescription
submitWithdraw(params)POST/api/v5/asset/withdrawalSubmit an on-chain withdrawal
submitWithdrawLightning(params)POST/api/v5/asset/withdrawal-lightningWithdraw via Lightning Network
cancelWithdrawal(params)POST/api/v5/asset/cancel-withdrawalCancel a pending withdrawal
getWithdrawalHistory(params?)GET/api/v5/asset/withdrawal-historyWithdrawal history
getDepositWithdrawStatus(params)GET/api/v5/asset/deposit-withdraw-statusReal-time status of a deposit or withdrawal

Currency conversion

MethodHTTPEndpointDescription
getConvertCurrencies()GET/api/v5/asset/convert/currenciesCurrencies available for conversion
getConvertCurrencyPair(params)GET/api/v5/asset/convert/currency-pairConversion pair details and limits
estimateConvertQuote(params)POST/api/v5/asset/convert/estimate-quoteGet a real-time conversion quote
convertTrade(params)POST/api/v5/asset/convert/tradeExecute a conversion using a quote
getConvertHistory(params?)GET/api/v5/asset/convert/historyConversion transaction history

Examples

Get funding account balances

import { RestClient } from 'okx-api';

const client = new RestClient({
  apiKey: process.env.API_KEY!,
  apiSecret: process.env.API_SECRET!,
  apiPass: process.env.API_PASS!,
});

// All funding balances
const balances = await client.getBalances();
for (const b of balances) {
  console.log(`${b.ccy}: available=${b.availBal}, frozen=${b.frozenBal}`);
}

// Single currency
const [usdtBalance] = await client.getBalances({ ccy: 'USDT' });
console.log('USDT funding balance:', usdtBalance.availBal);

Transfer from funding to trading account

const result = await client.fundsTransfer({
  ccy: 'USDT',
  amt: '100',
  from: '6',   // '6' = funding account
  to: '18',    // '18' = trading account
});
console.log('Transfer ID:', result[0].transId);

// Check transfer state
const state = await client.getFundsTransferState({
  transId: result[0].transId,
});
console.log('Status:', state[0].state); // 'success', 'pending', 'failed'

Get deposit address

const addresses = await client.getDepositAddress({ ccy: 'USDT' });
for (const addr of addresses) {
  console.log(`Chain: ${addr.chain}, Address: ${addr.addr}`);
  if (addr.tag) console.log(`Memo/Tag: ${addr.tag}`);
}

Submit a withdrawal

const [withdrawal] = await client.submitWithdraw({
  ccy: 'USDT',
  amt: '50',
  dest: '4',                          // '4' = on-chain
  toAddr: '0xYourAddressHere',
  chain: 'USDT-ERC20',
});
console.log('Withdrawal ID:', withdrawal.wdId);
Double-check the chain value against getCurrencies() output. Sending to the wrong chain results in permanent loss of funds.

Currency conversion

// 1. Get a quote to convert 100 USDT to BTC
const [quote] = await client.estimateConvertQuote({
  baseCcy: 'BTC',
  quoteCcy: 'USDT',
  side: 'sell',          // sell base (BTC) for quote (USDT)
  rfqSz: '100',          // amount in rfqSzCcy
  rfqSzCcy: 'USDT',
  quoteId: '',           // leave blank for initial request
});

console.log('You will receive:', quote.toAmt, quote.toCcy);
console.log('Quote ID:', quote.quoteId);
console.log('Quote expires:', quote.clQReqId);

// 2. Execute the conversion using the quote
const [trade] = await client.convertTrade({
  quoteId: quote.quoteId,
  baseCcy: 'BTC',
  quoteCcy: 'USDT',
  side: 'sell',
  sz: '100',
  szCcy: 'USDT',
});
console.log('Conversion trade ID:', trade.tradeId);

Query deposit history

const deposits = await client.getDepositHistory({
  ccy: 'BTC',
  limit: '20',
});

for (const d of deposits) {
  console.log(`${d.ccy} deposit: ${d.amt} - state: ${d.state} - txId: ${d.txId}`);
}

Key parameter types

interface FundsTransferRequest {
  ccy: string;          // Currency (e.g. 'USDT')
  amt: string;          // Amount as string
  from: '6' | '18';    // Source: '6'=funding, '18'=trading
  to: '6' | '18';      // Destination: '6'=funding, '18'=trading
  subAcct?: string;     // Sub-account name (for inter-account transfers)
  type?: '0' | '1' | '2' | '3' | '4'; // Transfer type
  clientId?: string;    // Client-assigned transfer ID
}
interface WithdrawRequest {
  ccy: string;           // Currency to withdraw
  amt: string;           // Amount
  dest: '3' | '4';      // '3'=internal transfer, '4'=on-chain
  toAddr: string;        // Destination address
  chain?: string;        // Chain name (e.g. 'USDT-ERC20')
  clientId?: string;     // Client-assigned ID
  rcvrInfo?: {           // Required for certain regulated entities
    walletType: 'exchange' | 'private';
    exchId?: string;
    rcvrFirstName?: string;
    rcvrLastName?: string;
  };
}
interface GetDepositHistoryRequest {
  ccy?: string;       // Filter by currency
  depId?: string;     // Deposit ID
  txId?: string;      // On-chain transaction hash
  type?: '3' | '4';  // '3'=internal, '4'=on-chain
  state?: '0' | '1' | '2' | '8' | '11' | '12' | '13' | '14' | '17';
  after?: string;     // Unix ms pagination cursor
  before?: string;
  limit?: string;     // Max 100
}

Build docs developers (and LLMs) love