Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/tiagosiebler/binance/llms.txt

Use this file to discover all available pages before exploring further.

USDMClient is the dedicated REST client for Binance’s USD-M Futures market. It connects to the fapi*.binance.com subdomains and exposes typed methods for perpetual and delivery futures contracts settled in USDT or BUSD. Whether you need to query mark prices and funding rates, manage leveraged positions, place complex multi-leg orders, or retrieve income history, USDMClient provides a complete interface to the USD-M Futures REST API.
Futures trading carries significant risk, including the possibility of losing more than your initial margin. Always test strategies against the testnet or Demo Trading environment before deploying with real funds.

Installation

1

Install the package

npm install binance
2

Import USDMClient

import { USDMClient } from 'binance';
// CommonJS: const { USDMClient } = require('binance');
3

Instantiate the client

const client = new USDMClient({
  api_key: process.env.BINANCE_API_KEY,
  api_secret: process.env.BINANCE_API_SECRET,
});

Constructor Options

const client = new USDMClient(
  restClientOptions,  // RestClientOptions (optional)
  requestOptions,     // AxiosRequestConfig (optional)
);
api_key
string
Your Binance API key. Required for all authenticated (private) endpoints.
api_secret
string
Your Binance API secret. Supports HMAC, RSA, and Ed25519 — key type is detected automatically.
beautifyResponses
boolean
default:"false"
When true, numeric strings in responses are parsed to JavaScript numbers for well-known fields.
testnet
boolean
default:"false"
Routes requests to https://testnet.binancefuture.com (fapi testnet). The testnet uses simulated market data — not recommended for strategy validation.
demoTrading
boolean
default:"false"
Routes requests to Binance’s USD-M Futures Demo Trading environment. Uses real market data with simulated order execution — the preferred option for testing trading strategies.
Set demoTrading: true during development to test with real market prices and simulated order fills. Switch to testnet: true only if you need the Binance Futures Testnet specifically (e.g., for SDK end-to-end tests).

Base URL

ModeBase URL
Productionhttps://fapi.binance.com
Testnethttps://testnet.binancefuture.com
Demo Tradinghttps://testnet.binancefuture.com (demo flag applied)

Method Categories

Market Data

Public endpoints — no API key required.
MethodEndpointDescription
testConnectivity()GET fapi/v1/pingTest REST API connectivity
getExchangeInfo()GET fapi/v1/exchangeInfoExchange rules, filters, and symbol info
getOrderBook(params)GET fapi/v1/depthOrder book for a symbol
getRecentTrades(params)GET fapi/v1/tradesRecent trades
getAggregateTrades(params)GET fapi/v1/aggTradesCompressed aggregate trades
getKlines(params)GET fapi/v1/klinesCandlestick data
getContinuousContractKlines(params)GET fapi/v1/continuousKlinesContinuous contract klines
getMarkPrice(params?)GET fapi/v1/premiumIndexMark price and funding rate
getFundingRateHistory(params?)GET fapi/v1/fundingRateHistorical funding rates
getFundingRates()GET fapi/v1/fundingInfoCurrent funding rates for all symbols
get24hrChangeStatistics(params?)GET fapi/v1/ticker/24hr24-hour rolling window price change
getSymbolPriceTicker(params?)GET fapi/v1/ticker/priceLatest price for symbol(s)
getSymbolPriceTickerV2(params?)GET fapi/v2/ticker/priceLatest price (v2)
getSymbolOrderBookTicker(params?)GET fapi/v1/ticker/bookTickerBest bid/ask price and quantity
getOpenInterest(params)GET fapi/v1/openInterestCurrent open interest
getOpenInterestStatistics(params)GET futures/data/openInterestHistHistorical open interest
getTopTradersLongShortPositionRatio(params)GET futures/data/topLongShortPositionRatioTop trader position ratio
getGlobalLongShortAccountRatio(params)GET futures/data/globalLongShortAccountRatioGlobal long/short ratio
getTakerBuySellVolume(params)GET futures/data/takerlongshortRatioTaker buy/sell volume ratio
getBasis(params)GET futures/data/basisBasis data for a contract

Order Management

Authenticated endpoints — require api_key and api_secret.
MethodEndpointDescription
submitNewOrder(params)POST fapi/v1/orderPlace a new futures order
submitMultipleOrders(orders)POST fapi/v1/batchOrdersPlace up to 5 orders in a single request
modifyOrder(params)PUT fapi/v1/orderModify an existing LIMIT order
modifyMultipleOrders(orders)PUT fapi/v1/batchOrdersModify up to 5 orders in one request
cancelOrder(params)DELETE fapi/v1/orderCancel an active order
cancelMultipleOrders(params)DELETE fapi/v1/batchOrdersCancel multiple orders
cancelAllOpenOrders(params)DELETE fapi/v1/allOpenOrdersCancel all open orders for a symbol
setCancelOrdersOnTimeout(params)POST fapi/v1/countdownCancelAllAuto-cancel orders after a timeout
getOrder(params)GET fapi/v1/orderQuery a specific order
getAllOrders(params)GET fapi/v1/allOrdersAll orders for a symbol
getAllOpenOrders(params?)GET fapi/v1/openOrdersAll open orders
getCurrentOpenOrder(params)GET fapi/v1/openOrderA specific open order
getOrderModifyHistory(params)GET fapi/v1/orderAmendmentOrder modification history
testOrder(params)POST fapi/v1/order/testTest order without execution

Position Management

MethodEndpointDescription
getPositionsV3(params?)GET fapi/v3/positionRiskCurrent positions (recommended)
getPositions(params?)GET fapi/v2/positionRiskCurrent positions (v2, deprecated)
setLeverage(params)POST fapi/v1/leverageSet leverage for a symbol
setMarginType(params)POST fapi/v1/marginTypeSwitch between ISOLATED/CROSSED margin
setIsolatedPositionMargin(params)POST fapi/v1/positionMarginAdjust isolated position margin
setPositionMode(params)POST fapi/v1/positionSide/dualToggle one-way / hedge mode
getCurrentPositionMode()GET fapi/v1/positionSide/dualQuery current position mode
getPositionMarginChangeHistory(params)GET fapi/v1/positionMargin/historyMargin change history
getADLQuantileEstimation(params?)GET fapi/v1/adlQuantileADL quantile estimation
getNotionalAndLeverageBrackets(params?)GET fapi/v1/leverageBracketLeverage brackets per symbol

Account

MethodEndpointDescription
getAccountInformationV3()GET fapi/v3/accountFull account information (recommended)
getAccountInformation()GET fapi/v2/accountAccount information (v2, deprecated)
getBalanceV3()GET fapi/v3/balanceAccount balance per asset (recommended)
getBalance()GET fapi/v2/balanceAccount balance (v2, deprecated)
getAccountTrades(params)GET fapi/v1/userTradesTrade history for a symbol
getIncomeHistory(params?)GET fapi/v1/incomeIncome history (funding, realised P&L, etc.)
getAccountCommissionRate(params)GET fapi/v1/commissionRateCommission rates for a symbol
getFuturesAccountConfig()GET fapi/v1/accountConfigAccount-level configuration
getMultiAssetsMode()GET fapi/v1/multiAssetsMarginMulti-assets margin mode status
setMultiAssetsMode(params)POST fapi/v1/multiAssetsMarginEnable/disable multi-assets margin mode

Algo Orders

MethodEndpointDescription
submitNewAlgoOrder(params)POST fapi/v1/algoOrderPlace a futures algo order (TWAP/VP)
cancelAlgoOrder(params)DELETE fapi/v1/algoOrderCancel a running algo order
cancelAllAlgoOpenOrders(params)DELETE fapi/v1/algoOpenOrdersCancel all open algo orders for a symbol
getAlgoOrder(params)GET fapi/v1/algoOrderQuery a specific algo order
getOpenAlgoOrders(params?)GET fapi/v1/openAlgoOrdersAll open algo orders
getAllAlgoOrders(params)GET fapi/v1/allAlgoOrdersFull algo order history

Code Examples

import { USDMClient } from 'binance';

// No credentials needed for public endpoints
const client = new USDMClient({ testnet: true });

async function fetchFuturesData() {
  // Mark price and funding rate
  const markPrice = await client.getMarkPrice({ symbol: 'BTCUSDT' });
  console.log('Mark price:', markPrice.markPrice);
  console.log('Funding rate:', markPrice.lastFundingRate);

  // Recent trades
  const trades = await client.getRecentTrades({ symbol: 'BTCUSDT', limit: 5 });
  console.log('Recent trades:', trades);

  // Open interest
  const oi = await client.getOpenInterest({ symbol: 'BTCUSDT' });
  console.log('Open interest:', oi.openInterest);
}

fetchFuturesData().catch(console.error);

Testing Environments

Demo Trading uses live market data with simulated order fills. It is the recommended environment for testing strategies.
const client = new USDMClient({
  api_key: 'YOUR_DEMO_API_KEY',
  api_secret: 'YOUR_DEMO_API_SECRET',
  demoTrading: true,
});
Create a Demo Trading account at Binance Demo Trading.

Full Endpoint Map

A complete reference of every USDMClient method, its authentication requirement, HTTP method, and target endpoint: REST Endpoint Function List →

Build docs developers (and LLMs) love