Skip to content

Binance API SDK ​

binance provides JavaScript and TypeScript clients for Binance REST and WebSocket APIs, covering market data, account queries and trading.

Build trading bots and automate your Binance strategies in Node.js, or use real-time market data in a dashboard. Start with a public price request, then add authentication and order handling for your trading workflow.

JavaScript & TypeScript · v3.6.11 · MIT license

Installation ​

TypeScript definitions are included.

sh
npm install binance
sh
pnpm add binance
sh
yarn add binance

Choose your setup ​

Start with the tools you already use. Each guide includes a complete project, setup commands, expected output and cleanup where applicable.

  • Node.js / JavaScript: run plain JavaScript with import or require, without a TypeScript compiler.
  • Node.js / TypeScript: type-check and compile a Node.js price and subscription script.
  • React: display live prices in a React component with effect cleanup, using Vite.
  • Vite (plain JavaScript): display prices in a browser page without React.
  • Next.js: return a price from a Node.js server Route Handler.
  • React Native / Expo: display prices and stop subscriptions on iOS and Android.
  • Bun and Deno: run a price and WebSocket script in your chosen runtime.

Each guide includes a downloadable starter generated from the maintained examples and runtime configuration. Runtime compatibility records tested versions and scope.

Usage ​

This request reads the BTCUSDT Spot price and requires no API key.

js
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;
});

The example prints the BTCUSDT price. See the Node.js quickstart to run it.

Choose a client ​

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.

Next steps ​

For a longer walkthrough, see the Binance JavaScript tutorial on Siebly.io.

Built by Siebly. Open source SDKs for exchange APIs.