Skip to main content
Earn and finance endpoints span staking, savings, and lending products. Authentication is required for order placement, redemption, and balance queries. Some public endpoints (APY history, lending offers) do not require credentials.

Method reference

On-chain earn / staking

MethodHTTPAuthEndpointDescription
getStakingOffers(params?)GETYes/api/v5/finance/staking-defi/offersAvailable staking and DeFi offers
submitStake(params)POSTYes/api/v5/finance/staking-defi/purchaseStake into a product
redeemStake(params)POSTYes/api/v5/finance/staking-defi/redeemRedeem a staking position
cancelStakingRequest(params)POSTYes/api/v5/finance/staking-defi/cancelCancel a pending stake/redeem
getActiveStakingOrders(params?)GETYes/api/v5/finance/staking-defi/orders-activeActive earn orders
getStakingOrderHistory(params?)GETYes/api/v5/finance/staking-defi/orders-historyHistorical earn orders

ETH staking

MethodHTTPAuthEndpointDescription
getETHStakingProductInfo()GETNo/api/v5/finance/staking-defi/eth/product-infoETH staking product details
purchaseETHStaking(params)POSTYes/api/v5/finance/staking-defi/eth/purchaseStake ETH
redeemETHStaking(params)POSTYes/api/v5/finance/staking-defi/eth/redeemRedeem staked ETH
cancelRedeemETHStaking(params)POSTYes/api/v5/finance/staking-defi/eth/cancel-redeemCancel an ETH redemption
getETHStakingBalance()GETYes/api/v5/finance/staking-defi/eth/balanceETH staking balance
getETHStakingHistory(params)GETYes/api/v5/finance/staking-defi/eth/purchase-redeem-historyETH staking/redemption history
getAPYHistory(params)GETNo/api/v5/finance/staking-defi/eth/apy-historyHistorical APY for ETH staking

Simple earn (flexible savings)

MethodHTTPAuthEndpointDescription
getSavingBalance(params?)GETYes/api/v5/finance/savings/balanceFlexible savings balance
savingsPurchaseRedemption(params)POSTYes/api/v5/finance/savings/purchase-redemptPurchase or redeem savings
setLendingRate(params)POSTYes/api/v5/finance/savings/set-lending-rateSet minimum lending rate
getLendingHistory(params?)GETYes/api/v5/finance/savings/lending-historyLending earnings history
getPublicBorrowInfo(params?)GETNo/api/v5/finance/savings/lending-rate-summaryPublic lending rate summary
getPublicBorrowHistory(params?)GETNo/api/v5/finance/savings/lending-rate-historyPublic lending rate history

Fixed-term lending

MethodHTTPAuthEndpointDescription
getLendingOffers(params?)GETNo/api/v5/finance/fixed-loan/lending-offersAvailable fixed lending offers
getLendingAPYHistory(params)GETNo/api/v5/finance/fixed-loan/lending-apy-historyAPY history for fixed lending
getLendingVolume(params)GETNo/api/v5/finance/fixed-loan/pending-lending-volumePending lending volume
placeLendingOrder(params)POSTYes/api/v5/finance/fixed-loan/lending-orderPlace a fixed lending order
amendLendingOrder(params)POSTYes/api/v5/finance/fixed-loan/amend-lending-orderAmend a fixed lending order
getLendingOrders(params)GETYes/api/v5/finance/fixed-loan/lending-orders-listFixed lending order list
getLendingSubOrders(params)GETYes/api/v5/finance/fixed-loan/lending-sub-ordersFixed lending sub-orders

Flexible loan

MethodHTTPAuthEndpointDescription
getBorrowableCurrencies()GETNo/api/v5/finance/flexible-loan/borrow-currenciesCurrencies available to borrow
getCollateralAssets(params?)GETNo/api/v5/finance/flexible-loan/collateral-assetsSupported collateral assets
getMaxLoanAmount(params)POSTYes/api/v5/finance/flexible-loan/max-loanMaximum borrowable amount
adjustCollateral(params)POSTYes/api/v5/finance/flexible-loan/adjust-collateralAdjust collateral
getLoanInfo()GETYes/api/v5/finance/flexible-loan/loan-infoCurrent flexible loan info
getLoanHistory(params?)GETYes/api/v5/finance/flexible-loan/loan-historyFlexible loan history
getAccruedInterest(params?)GETYes/api/v5/finance/flexible-loan/interest-accruedAccrued flexible loan interest

Examples

Browse and stake a DeFi product

import { RestClient } from 'okx-api';

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

// 1. Find available staking offers for USDT
const offers = await client.getStakingOffers({ ccy: 'USDT' });
const offer = offers[0];
console.log(`Product: ${offer.productId}, APY: ${offer.apy}`);

// 2. Stake 100 USDT into the product
const [order] = await client.submitStake({
  productId: offer.productId,
  investData: [{ ccy: 'USDT', amt: '100' }],
});
console.log('Stake order ID:', order.ordId);

// 3. View active orders
const active = await client.getActiveStakingOrders({ ccy: 'USDT' });
console.log('Active staking orders:', active.length);

Redeem a staking position

const [result] = await client.redeemStake({
  ordId: 'your-order-id',
  protocolType: 'staking',
  allowEarlyRedeem: true,
});
console.log('Redemption order ID:', result.ordId);

ETH staking

// Get ETH staking product details (no auth needed)
const client = new RestClient();
const productInfo = await client.getETHStakingProductInfo();
console.log('ETH staking APY:', productInfo[0]?.apy);

// Check historical APY
const apyHistory = await client.getAPYHistory({ days: '7' });
for (const entry of apyHistory) {
  console.log(`${entry.date}: ${entry.apy}`);
}
// Stake ETH (requires auth)
const authClient = new RestClient({
  apiKey: process.env.API_KEY!,
  apiSecret: process.env.API_SECRET!,
  apiPass: process.env.API_PASS!,
});

await authClient.purchaseETHStaking({ amt: '0.5' });
const [ethBalance] = await authClient.getETHStakingBalance();
console.log('ETH staking balance:', ethBalance.amt);

Simple earn savings

// Purchase flexible savings
const [result] = await client.savingsPurchaseRedemption({
  ccy: 'USDT',
  amt: '1000',
  side: 'purchase',
  rate: '0.01',  // minimum lending rate (1%)
});
console.log('Savings amount:', result.amt);

// Check balance
const savingsBalance = await client.getSavingBalance({ ccy: 'USDT' });
console.log('Savings:', savingsBalance[0]?.amt);
console.log('Earnings:', savingsBalance[0]?.earnings);

// Redeem
await client.savingsPurchaseRedemption({
  ccy: 'USDT',
  amt: '1000',
  side: 'redempt',
  rate: '0.01',
});

Build docs developers (and LLMs) love