Professional Node.js & JavaScript SDK for Binance REST APIs and WebSockets, supporting Spot, Margin, Isolated Margin, Options, USDM & CoinM Futures. Current stable version is 3.5.9, with frequent releases and automated end-to-end tests ensuring stability. Key differentiators: strong TypeScript support with typed requests/responses and WebSocket events, smart WebSocket reconnection and listenKey management, support for HMAC, RSA, and Ed25519 authentication, and optional automatic beautification of API responses.
npm install binanceNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Initializes the MainClient with API credentials from environment variables and retrieves the spot account info.
Use ESM imports (import { MainClient } from 'binance') or switch to CJS-compatible bundler (e.g., webpack, esbuild) with ESM interop.Use import { WebsocketClient } from 'binance' instead of 'binance/lib/websocket'.Update your WebsocketClient config: new WebsocketClient({ wssUrl: '...', wsOptions: {...} })Ensure private key is a raw base64 string without PEM headers.
Use restOptions: { baseUrl: '...' } instead of baseURL: '...'.Change const { MainClient } = require('binance') to import { MainClient } from 'binance' (use ESM or set type: 'module' in package.json).Enable automatic listenKey management in WebsocketClient options: { wsOptions: { autoListenKeyRefresh: true } } or manually refresh via REST API.Implement rate limiting or retry logic; use the SDK's built-in throttling if available (set restOptions: { recvWindow: 5000, requestOptions: { retry: 3 } }).Install node-fetch: npm install node-fetch, or upgrade Node.js to >= 18 which has native fetch.
Upgrade Node.js to >= 16 LTS or use a transpiler like Babel.