Trading Bots

How to Connect to Binance WebSocket for Real-Time Market Data

Published on 2026-03-07 | 2 min

How to connect to the Binance WebSocket API for real-time data streams.

For quantitative trading or market monitoring, WebSocket is the best way to get real-time Binance data — lower latency and higher efficiency than REST API polling.

Register on Binance for API access. Download the Binance app.

Base URL

Spot: wss://stream.binance.com:9443/ws/ Combined streams: wss://stream.binance.com:9443/stream?streams=stream1/stream2

Common Stream Types

  • Trade: btcusdt@trade (every trade)
  • Kline: btcusdt@kline_1m (candlestick updates)
  • Depth: btcusdt@depth@100ms (order book changes)
  • Ticker: btcusdt@ticker (24h stats)

Connection Steps

  1. Choose a WebSocket library (Python: websocket-client; JS: ws)
  2. Connect with stream names
  3. Parse incoming JSON messages
  4. Implement auto-reconnect (connections drop every 24h)

Notes

Max 200 streams per connection. Public data doesn't need API keys. User data streams (orders, balance changes) need a listenKey from REST API (refresh every 60 minutes).