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.

CoinMClient provides typed access to the Binance COIN-M (Coin-Margined) Futures REST API (dapi/v1, dapi/v2). Unlike USD-M futures where margin and PnL are denominated in stablecoins, COIN-M futures are margined and settled in the underlying cryptocurrency (e.g. BTC, ETH). The client handles authentication, request signing, and time-drift correction automatically.
The complete endpoint-to-function mapping for CoinMClient is available in the endpointFunctionList reference on GitHub.

Installation & Instantiation

import { CoinMClient } from 'binance';

// Public (market data only)
const publicClient = new CoinMClient();

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

// Testnet
const testClient = new CoinMClient({ testnet: true });

Market Data

These methods are public — no API key is required.
MethodHTTPEndpointDescription
testConnectivity()GETdapi/v1/pingTest server connectivity
getExchangeInfo()GETdapi/v1/exchangeInfoExchange info, symbols, and filters
getOrderBook(params)GETdapi/v1/depthOrder book depth
getRecentTrades(params)GETdapi/v1/tradesRecent trades for a symbol
getHistoricalTrades(params)GETdapi/v1/historicalTradesOlder market trades
getAggregateTrades(params)GETdapi/v1/aggTradesCompressed / aggregate trade list
getMarkPrice(params?)GETdapi/v1/premiumIndexMark price and funding rate
getFundingRateHistory(params?)GETdapi/v1/fundingRateHistorical funding rates
getFundingRate(params?)GETdapi/v1/fundingInfoCurrent funding info for all symbols
getKlines(params)GETdapi/v1/klinesKline / candlestick data
getContinuousContractKlines(params)GETdapi/v1/continuousKlinesContinuous contract klines
getIndexPriceKlines(params)GETdapi/v1/indexPriceKlinesIndex price klines
getMarkPriceKlines(params)GETdapi/v1/markPriceKlinesMark price klines
getPremiumIndexKlines(params)GETdapi/v1/premiumIndexKlinesPremium index klines
get24hrChangeStatistics(params?)GETdapi/v1/ticker/24hr24-hour rolling statistics
getSymbolPriceTicker(params?)GETdapi/v1/ticker/priceLatest price
getSymbolOrderBookTicker(params?)GETdapi/v1/ticker/bookTickerBest bid/ask
getOpenInterest(params)GETdapi/v1/openInterestPresent open interest
getOpenInterestStatistics(params)GETfutures/data/openInterestHistHistorical open interest
getTopTradersLongShortAccountRatio(params)GETfutures/data/topLongShortAccountRatioTop trader account ratio
getTopTradersLongShortPositionRatio(params)GETfutures/data/topLongShortPositionRatioTop trader position ratio
getGlobalLongShortAccountRatio(params)GETfutures/data/globalLongShortAccountRatioGlobal long/short account ratio
getTakerBuySellVolume(params)GETfutures/data/takerBuySellVolTaker buy/sell volume
getCompositeSymbolIndex(params)GETfutures/data/basisComposite symbol / basis data
getIndexPriceConstituents(params)GETdapi/v1/constituentsIndex price constituents
getQuarterlyContractSettlementPrices(params)GETfutures/data/delivery-priceQuarterly contract settlement prices

Code Example — Market Data

import { CoinMClient } from 'binance';

const client = new CoinMClient();

// Current mark price for BTCUSD perpetual
const mark = await client.getMarkPrice({ symbol: 'BTCUSD_PERP' });
console.log('Mark price:', (mark as any).markPrice);

// Klines
const klines = await client.getKlines({
  symbol: 'BTCUSD_PERP',
  interval: '4h',
  limit: 10,
});
console.log('Klines count:', klines.length);

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

Order Management

All methods in this section require authentication.
MethodHTTPEndpointDescription
submitNewOrder(params)POSTdapi/v1/orderPlace a new COIN-M futures order
submitMultipleOrders(orders)POSTdapi/v1/batchOrdersPlace up to 5 orders in a batch
modifyOrder(params)PUTdapi/v1/orderModify an existing LIMIT order
modifyMultipleOrders(orders)PUTdapi/v1/batchOrdersModify multiple orders in batch
getOrderModifyHistory(params)GETdapi/v1/orderAmendmentOrder modification history
cancelOrder(params)DELETEdapi/v1/orderCancel a specific order
cancelMultipleOrders(params)DELETEdapi/v1/batchOrdersCancel multiple orders by ID list
cancelAllOpenOrders(params?)DELETEdapi/v1/allOpenOrdersCancel all open orders
setCancelOrdersOnTimeout(params)POSTdapi/v1/countdownCancelAllAuto-cancel all orders after timeout
getOrder(params)GETdapi/v1/orderQuery a specific order
getAllOrders(params)GETdapi/v1/allOrdersAll orders (open, cancelled, filled)
getAllOpenOrders(params?)GETdapi/v1/openOrdersAll current open orders
getCurrentOpenOrder(params)GETdapi/v1/openOrderQuery a single specific open order
getForceOrders(params?)GETdapi/v1/forceOrdersForced liquidation orders
getAccountTrades(params)GETdapi/v1/userTradesAccount trade list

Code Example — Order Management

import { CoinMClient } from 'binance';

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

// Place a market order
const order = await client.submitNewOrder({
  symbol: 'BTCUSD_PERP',
  side: 'BUY',
  type: 'MARKET',
  quantity: 1, // number of contracts
});
console.log('Filled at avg price:', order.avgPrice);

// View all open orders
const openOrders = await client.getAllOpenOrders({ symbol: 'BTCUSD_PERP' });
console.log('Open orders:', openOrders.length);

Position Management

MethodHTTPEndpointDescription
setPositionMode(params)POSTdapi/v1/positionSide/dualToggle Hedge Mode
setMarginType(params)POSTdapi/v1/marginTypeSwitch between CROSSED and ISOLATED margin
setLeverage(params)POSTdapi/v1/leverageSet leverage for a symbol
setIsolatedPositionMargin(params)POSTdapi/v1/positionMarginAdjust isolated margin
getPositions(params?)GETdapi/v1/positionRiskCurrent position information
getPositionMarginChangeHistory(params)GETdapi/v1/positionMargin/historyIsolated margin change history
getADLQuantileEstimation(params?)GETdapi/v1/adlQuantileADL quantile estimation
getCurrentPositionMode()GETdapi/v1/positionSide/dualQuery current position mode
getNotionalAndLeverageBrackets(params?)GETdapi/v2/leverageBracketNotional and leverage brackets

Account

MethodHTTPEndpointDescription
getBalance()GETdapi/v1/balanceAccount balance per asset
getAccountInformation()GETdapi/v1/accountFull account information
getAccountCommissionRate(params)GETdapi/v1/commissionRateCommission rates for a symbol
getIncomeHistory(params?)GETdapi/v1/incomeIncome / PnL history
getDownloadIdForFuturesTransactionHistory(params)GETdapi/v1/income/asynGet download ID for transaction history
getFuturesTransactionHistoryDownloadLink(params)GETdapi/v1/income/asyn/idGet download link for transaction history
getDownloadIdForFuturesOrderHistory(params)GETdapi/v1/order/asynGet download ID for order history
getFuturesOrderHistoryDownloadLink(params)GETdapi/v1/order/asyn/idGet download link for order history
getDownloadIdForFuturesTradeHistory(params)GETdapi/v1/trade/asynGet download ID for trade history
getFuturesTradeHistoryDownloadLink(params)GETdapi/v1/trade/asyn/idGet download link for trade history

Portfolio Margin (Classic)

MethodHTTPEndpointDescription
getClassicPortfolioMarginAccount(params)GETdapi/v1/pmAccountInfoClassic Portfolio Margin account info
getClassicPortfolioMarginNotionalLimits(params?)GETdapi/v1/pmExchangeInfoClassic PM notional limits (deprecated)

Full Usage Example

import { CoinMClient } from 'binance';

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

async function main() {
  // Account balances
  const balances = await client.getBalance();
  const btcBalance = balances.find((b) => b.asset === 'BTC');
  console.log('BTC available:', btcBalance?.availableBalance);

  // Full account info
  const account = await client.getAccountInformation();
  console.log('Total unrealised PnL:', account.totalUnrealizedProfit);

  // Leverage and margin setup
  await client.setLeverage({ symbol: 'BTCUSD_PERP', leverage: 5 });
  await client.setMarginType({ symbol: 'BTCUSD_PERP', marginType: 'CROSSED' });

  // Current positions
  const positions = await client.getPositions({ pair: 'BTCUSD' });
  console.log('BTCUSD positions:', positions.length);

  // Income history
  const pnl = await client.getIncomeHistory({
    symbol: 'BTCUSD_PERP',
    incomeType: 'REALIZED_PNL',
    limit: 10,
  });
  console.log('Last PnL entry:', pnl[0]?.income);
}

main();
COIN-M contracts use contract quantity (number of contracts), not asset quantity, when placing orders. One BTC quarterly contract typically represents 100 USD worth of BTC; check getExchangeInfo() for the exact contract multiplier per symbol.

Build docs developers (and LLMs) love