Skip to content

Clients ​

Binance has separate REST clients for Spot, futures and Portfolio Margin. WebSocket clients handle streaming updates and request-response operations.

ClientPurpose
MainClientSpot and related account endpoints over HTTP.
USDMClientUSD-M futures endpoints.
CoinMClientCOIN-M futures endpoints.
PortfolioClientPortfolio Margin endpoints.
WebsocketClientMarket and account streams, with raw message events and optional formatted events.
WebsocketAPIClientSupported awaitable operations over Binance WebSocket APIs.

REST requests ​

ts
import { MainClient } from 'binance';

async function main() {
  const client = new MainClient();
  const result = await client.getSymbolPriceTicker({ symbol: 'BTCUSDT' });
  if (Array.isArray(result)) throw new Error('Expected a single-symbol ticker.');
  console.log('BTCUSDT last price:', result.price);
}
main().catch((error) => {
  console.error(error instanceof Error ? error.message : 'Request failed. See the troubleshooting guide.');
  process.exitCode = 1;
});

getSymbolPriceTicker() returns response data directly. Its return type allows one ticker or an array; the example handles both before reading price.

WebSocket subscriptions ​

Register listeners before subscribing with WebsocketClient. The subscription example shows message handling and shutdown.

WebSocket API requests ​

WebsocketAPIClient returns promises for supported Binance WebSocket API operations. Its method list differs from the REST clients.

Full reference ​

Built by Siebly. Open source SDKs for exchange APIs.