TheDocumentation 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 npm package is a professional, production-grade Node.js and TypeScript SDK for the full Binance API surface. It handles request building, authentication, timestamp synchronization, WebSocket lifecycle management, and response parsing — so your code can stay focused on the trading logic you’re building. Whether you need Spot market data, authenticated Futures orders, or a persistent WebSocket stream, every Binance product group is covered by a dedicated, strongly typed client.
What the SDK covers
Binance exposes multiple distinct API families, each with its own endpoint prefix, subdomain, and account model. The SDK maps directly to those product groups:| Product group | REST client | Common usage |
|---|---|---|
| Spot, Margin, Wallet, Convert, Earn, Sub-accounts | MainClient | Spot trading, account data, wallet flows, transfers, savings |
USD-M Futures (fapi/) | USDMClient | USDT/USDC-margined futures, positions, orders |
COIN-M Futures (dapi/) | CoinMClient | Coin-margined futures, positions, orders |
Portfolio Margin (papi/) | PortfolioClient | Unified margin account, UM/CM/margin orders |
| WebSocket streams | WebsocketClient | Public market data & private user data streams |
| WebSocket API | WebsocketAPIClient | REST-like commands over persistent WebSocket connections |
Key features
Full TypeScript support
Every request parameter and API response is strongly typed. Type declarations are bundled — no separate
@types package required.All auth mechanisms
HMAC, RSA, and Ed25519 are all supported. Pass a PEM private key as
api_secret and the SDK auto-detects the key type.Smart WebSocket persistence
Automatic heartbeats, listen-key refresh, reconnection, and topic resubscription. Emits
reconnected so you can reconcile state via REST.Response beautification
Enable
beautifyResponses: true to parse known float-strings into numbers across REST responses and WebSocket events.Demo & testnet support
Switch to Binance demo trading (real market data, simulated fills) or testnet with a single constructor option.
Browser bundle support
A webpack config is included to build a browser bundle. See the README for frontend usage instructions.
Installation
import and CommonJS require() out of the box.
Exported clients at a glance
{ api_key, api_secret } constructor shape. Public market data endpoints work without credentials — just omit the keys. WebsocketClientLegacy is also exported for projects that depend on the older WebSocket connection model.
New projects should use
WebsocketClient rather than WebsocketClientLegacy. The legacy client is retained for backward compatibility.API credentials are scoped per environment. Live, demo trading, Spot testnet, and Futures testnet credentials are separate. Never mix them in the same client instance.
Navigation
Quickstart
Install the SDK, make your first public call, and place a test order in under 5 minutes.
Authentication
Configure HMAC, RSA, or Ed25519 auth and learn credential best practices.
Related links
GitHub repository
Source code, examples folder, and issue tracker.
npm package
Latest release, version history, and bundle size.
Binance API docs
Official Binance REST API and WebSocket documentation.
Endpoint function map
Full mapping of every Binance endpoint to its SDK method name.