Introduction
The Binance USD-M futures API lives on its own host, fapi.binance.com, with its own endpoints, filters and account settings. A first futures script usually needs five things: the trading rules for a symbol, the mark price and funding rate, some candles, the margin type and leverage, and an order. This article covers all five in Node.js and runs the private part against the Binance futures testnet, so no real funds are involved.
The examples use the binance package on npm, a community maintained, MIT licensed SDK for the Binance REST APIs and WebSockets with TypeScript types included. Its USDMClient covers the USD-M futures REST API. The code below was run on Node.js 24 with binance 3.6.15 on 3 December 2026.
npm install binanceSave the code as futures.ts and run it with npx tsx futures.ts, or rename it to .mjs and drop the type annotations.
Step 1: Trading rules from exchangeInfo
Every futures symbol has filters that decide which prices and quantities Binance accepts. The three that matter for a first order are PRICE_FILTER (tick size), LOT_SIZE (quantity step) and MIN_NOTIONAL (smallest order value in USDT).
import { USDMClient } from 'binance';
const market = new USDMClient();
const info = await market.getExchangeInfo();
const btc = info.symbols.find((s) => s.symbol === 'BTCUSDT')!;
const lot = btc.filters.find((f) => f.filterType === 'LOT_SIZE') as { stepSize: string; minQty: string };
const minNotional = btc.filters.find((f) => f.filterType === 'MIN_NOTIONAL') as { notional: string };
console.log('step', lot.stepSize, 'min qty', lot.minQty, 'min notional', minNotional.notional);On 3 December this printed step 0.001 min qty 0.001 min notional 50 for BTCUSDT. No API key is needed for any of the market data calls.
Step 2: Mark price, funding rate and candles
Futures positions are valued at the mark price, not the last trade, and funding is exchanged at set intervals. One call returns the mark price, the latest funding rate and the next funding time:
const mark = await market.getMarkPrice({ symbol: 'BTCUSDT' });
console.log('mark price', mark.markPrice, 'funding rate', mark.lastFundingRate,
'next funding', new Date(mark.nextFundingTime).toISOString());
const candles = await market.getKlines({ symbol: 'BTCUSDT', interval: '1h', limit: 24 });
const closes = candles.map((k) => Number(k[4]));
console.log('24h closes', closes.length, 'last', closes.at(-1));Each kline is an array: open time, open, high, low, close, volume and so on, with prices as strings. Index 4 is the close.
Step 3: Size the order from the filters
Binance rejects a quantity that is not a multiple of the step size, and an order whose value is below the minimum notional. A small helper rounds down to the step and keeps the string format Binance expects:
function toStep(value: number, step: string): string {
const decimals = step.includes('.') ? step.split('.')[1].replace(/0+$/, '').length : 0;
const units = Math.floor(value / Number(step) + 1e-9);
return (units * Number(step)).toFixed(decimals);
}
const quantity = toStep(100 / Number(mark.markPrice), lot.stepSize);
if (Number(quantity) * Number(mark.markPrice) < Number(minNotional.notional)) {
throw new Error('order too small');
}
Join the conversation! Your thoughts help the community grow.