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.

Binance provides dedicated market maker subdomains for qualified futures traders who participate in the Binance Futures Liquidity Provider Program. These endpoints are hosted on separate infrastructure from the standard public API and are designed to offer improved latency for high-frequency trading workflows. The Binance SDK exposes market maker endpoints through a single constructor option that can be set on both REST and WebSocket clients.
Market maker endpoints are only available to traders who have enrolled in and qualified for at least one of Binance’s Futures Liquidity Provider Programs. If you are not enrolled, useMMSubdomain: true will result in connection errors. More information on eligibility can be found in the Binance FAQ.

What Are Market Maker Endpoints?

Standard Binance futures API calls are routed through fapi.binance.com (USD-M) and dapi.binance.com (COIN-M). The market maker subdomains — fapi-mm.binance.com and dapi-mm.binance.com — are dedicated infrastructure paths that serve the same API surface but with routing optimised for the lower-latency requirements of high-frequency market making. The SDK resolves the correct URL automatically when useMMSubdomain: true is set:
ClientStandard endpointMarket maker endpoint
USDMClienthttps://fapi.binance.comhttps://fapi-mm.binance.com
CoinMClienthttps://dapi.binance.comhttps://dapi-mm.binance.com
WebsocketClient (USD-M)Standard WS endpointMM WS endpoint
WebsocketClient (COIN-M)Standard WS endpointMM WS endpoint
Market maker endpoints are available for USD-M and COIN-M futures only. MainClient (Spot), PortfolioClient, and testnet clients do not have corresponding market maker subdomains. Setting useMMSubdomain: true has no effect on those clients — they fall back to the standard endpoint silently.

Enabling Market Maker Endpoints

Set useMMSubdomain: true in the constructor options of USDMClient, CoinMClient, or WebsocketClient:
import { USDMClient } from 'binance';

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

  // Route all requests through the market maker subdomain
  useMMSubdomain: true,

  // Recommended: enable HTTP keep-alive to reduce per-request overhead
  keepAlive: true,
  keepAliveMsecs: 1000,
});

async function getAccountInfo() {
  try {
    const account = await client.getAccountInformation();
    console.log('MM account can trade:', account.canTrade);

    const positions = await client.getPositions({ symbol: 'BTCUSDT' });
    console.log('Open positions:', positions.length);
  } catch (e) {
    console.error('MM REST error:', e);
  }
}

getAccountInfo();

Compatibility with Other Options

useMMSubdomain can be combined with other client options, with two important restrictions:
  • Not compatible with testnet: true: There are no market maker endpoints for testnet (usdmtest, coinmtest). If testnet: true is set, the MM URL lookup returns undefined and the client falls back to the standard testnet URL. Do not combine these options with the expectation of using MM endpoints.
  • Not compatible with demoTrading: true: Demo trading endpoints also do not have market maker variants. The same fallback behaviour applies.
// ✅ Valid — production MM endpoints
const client = new USDMClient({
  api_key: process.env.BINANCE_API_KEY,
  api_secret: process.env.BINANCE_API_SECRET,
  useMMSubdomain: true,
});

// ❌ Avoid — testnet has no MM endpoints; useMMSubdomain is silently ignored
const testnetClient = new USDMClient({
  api_key: process.env.BINANCE_TESTNET_API_KEY,
  api_secret: process.env.BINANCE_TESTNET_API_SECRET,
  testnet: true,
  useMMSubdomain: true, // has no effect on testnet
});

Best Practices for Market Making

Following Binance’s guidance and the SDK’s capabilities, these practices are recommended for production market making integrations:
1

Use Ed25519 keys

Ed25519 authentication is recommended for latency-sensitive integrations. With Ed25519, the WebSocket API can authenticate a session once at connection time rather than signing every individual request. This removes per-request signing overhead from the hot path. Pass your Ed25519 PEM private key as api_secret — the SDK detects the key type automatically.
2

Enable HTTP keep-alive for REST

Set keepAlive: true on the REST client to reuse TCP connections. Each new connection involves a TLS handshake that adds latency. Keep-alive eliminates this overhead on subsequent requests from the same client instance.
3

Keep WebSocket connections alive

Use the SDK’s built-in heartbeat mechanism (enabled by default) to detect and recover from silent disconnections. Do not set disableHeartbeat: true in production. For critical paths, listen for reconnecting and reconnected events and reconcile state via REST on reconnect.
4

Verify eligibility before deploying

The MM subdomain will reject connections from accounts that are not enrolled in the Liquidity Provider Program. Test connectivity with a simple public endpoint call (e.g. client.getExchangeInfo()) immediately after instantiating the MM client to confirm access before placing orders.
import { USDMClient, WebsocketClient, DefaultLogger } from 'binance';

// Custom logger for production monitoring
const logger: typeof DefaultLogger = {
  ...DefaultLogger,
  trace: () => {},
  info: (...p) => console.info(new Date().toISOString(), '[MM]', ...p),
  error: (...p) => console.error(new Date().toISOString(), '[MM]', ...p),
};

// REST client with MM subdomain and keep-alive
const restClient = new USDMClient({
  api_key: process.env.BINANCE_API_KEY,
  // Ed25519 PEM private key for session-level WS API auth
  api_secret: process.env.BINANCE_API_SECRET,
  useMMSubdomain: true,
  keepAlive: true,
  keepAliveMsecs: 1000,
  recvWindow: 5000,
});

// Verify MM access on startup
const exchangeInfo = await restClient.getExchangeInfo();
console.log('MM REST API connected, symbols:', exchangeInfo.symbols.length);

// WebSocket client with MM subdomain
const wsClient = new WebsocketClient(
  {
    api_key: process.env.BINANCE_API_KEY,
    api_secret: process.env.BINANCE_API_SECRET,
    useMMSubdomain: true,
    beautify: true,
    recvWindow: 5000,
  },
  logger,
);

wsClient.on('reconnecting', ({ wsKey }) => {
  console.warn(`MM WebSocket reconnecting: ${wsKey} — pausing order activity`);
});

wsClient.on('reconnected', async ({ wsKey }) => {
  console.info(`MM WebSocket reconnected: ${wsKey} — reconciling state`);
  const positions = await restClient.getPositions();
  console.info('Positions after reconnect:', positions.length);
});

wsClient.on('exception', console.error);

await wsClient.subscribeUsdFuturesUserDataStream();

Build docs developers (and LLMs) love