SDK guide
JavaScript
REST API + WebSocket

Binance JavaScript SDK

Build with the Binance REST API & WebSockets with our JavaScript SDK, TypeScript-first package declarations, and Node.js-compatible runtime patterns. Discover installation, common examples, a detailed endpoint-to-function map, and the REST API/WebSocket patterns shared across our Siebly SDK family.

Use the same TypeScript-first REST API and WebSocket clients from plain JavaScript or TypeScript in Node.js-compatible runtimes.

Package surfaces

Explore the following API capabilities are covered by our Binance SDK:

  • Spot
  • Futures
  • Margin
  • WebSockets
  • WebSocket API
  • WebSocket clients with:
    • Built-in heartbeats.
    • Automatic reconnection.
    • Automatic reauthentication and resubscribe where the exchange supports it.
  • Promise-wrapped WebSocket API commands you can await like a REST API.
  • Typed requests and responses for Node.js, JavaScript, and TypeScript IDEs.
  • Framework-neutral JavaScript snippets that stay approachable in Node.js-compatible runtimes.
  • TypeScript-first package declarations for stricter services, shared libraries, and editor-assisted integrations.

Install Binance SDK

# Via your favourite package manager, e.g. npm:
npm install binance
# or pnpm:
pnpm install binance
# or yarn:
yarn add binance

Quickstart Examples with the Binance JavaScript SDK

Get started with just a few lines of JavaScript. TypeScript, while not required, is absolutely recommended. TypeScript declarations are included with all our SDKs and provide convenient definitions on request & response fields, WebSocket payloads, and generally safer integrations.

Quickstart snippets are currently unavailable for this SDK and language combination.

Showing cached quickstart content from build-time configuration.
Full Binance course

Binance API JavaScript Tutorial

A practical JavaScript guide to using binance across Binance Spot, margin, USD-M Futures, COIN-M Futures, Portfolio Margin, public streams, user data, WebSocket API commands, and production rollout checks.

Product-specific REST API clients
Public and user data WebSocket streams
WebSocket API request/response commands
Demo, testnet, and resilient networking
REST API
WebSocket Streams
WebSocket API
Examples

Your app / service

bot, dashboard, worker

binance

MainClient, USDMClient, WebsocketAPIClient

Binance APIs

Spot, Futures, Portfolio Margin, streams, WebSocket API

Common Binance implementation tasks

Start from the behavior you need, not just from REST or WebSocket as a transport. Market-data driven systems should be event driven. Backfill via the REST API once and let WebSockets passively stream new data to you, as it becomes available.

Endpoint Function Reference

Binance JavaScript FAQ

What does the Binance JavaScript SDK cover?

Binance supports Spot, Futures, Margin, WebSockets, and WebSocket API workflows. The JavaScript guide covers the main REST and WebSocket integration patterns.

How do I authenticate private Binance API calls in JavaScript?

Install binance from npm & pass API credentials into the SDK client options, as shown in the Binance JavaScript examples above. The SDK handles the exchange-specific signing requirements for private requests.

Does the Binance JavaScript SDK help with WebSocket connection management?

Yes. Use the SDK WebSocket client for subscriptions, reconnect handling, and stream lifecycle management instead of building raw socket flows yourself.

When should I use the Binance WebSocket API instead of REST?

Use REST for standard request and response workflows such as account queries and order management. Use the WebSocket API flow when you want persistent low-latency interactions over a connected session.

Direct Example Files

Continue with implementation resources