WebSocket Stream¶
General WSS Information¶
The base endpoint is:\
- wss://{broker_domain}:443
Streams can be accessed either in a single raw stream or in a combined stream.
- Raw streams are accessed at
/ws/<streamName> - Combined streams are accessed at
/stream?streams=<streamName1>/<streamName2>/<streamName3>
Combined stream events are wrapped as follows:
{"stream":"<streamName>","data":<rawPayload>}
- All symbols for streams are lowercase
- A single connection to
stream.binance.comis valid only for 24 hours - The WebSocket server sends a ping every 20 seconds
- If no pong is received within 1 minute, the connection will be closed
- Pong must contain the ping's payload (can be empty for unsolicited pong)
- The endpoint
wss://data-stream.binance.visionprovides only market data, no user streams - Timestamps are in milliseconds by default, use
timeUnit=MICROSECONDto switch
WebSocket Limits¶
- Max 5 incoming messages per second (ping, pong, subscribe/unsubscribe, etc.)\
- Max 1024 streams per connection\
- Max 300 connection attempts per 5 minutes per IP
Live Subscribing/Unsubscribing¶
- Requests include
"method","params", and"id"\ "id"can be int64, alphanumeric string (36 max), or null\- A response with
"result": nullmeans success
Subscribe
{
"method": "SUBSCRIBE",
"params": ["btcusdt@aggTrade","btcusdt@depth"],
"id": 1
}
Unsubscribe
{
"method": "UNSUBSCRIBE",
"params": ["btcusdt@depth"],
"id": 312
}
List Subscriptions
{"method": "LIST_SUBSCRIPTIONS","id": 3}
Properties¶
"combined": true/false
Set Property
{"method": "SET_PROPERTY","params":["combined",true],"id":5}
Get Property
{"method": "GET_PROPERTY","params":["combined"],"id":2}
Error Messages¶
Code Message Description
0 Unknown property Invalid parameter in SET/GET_PROPERTY 1 Invalid value type Expected Boolean 2 Invalid request Wrong type or missing field 3 Invalid JSON Syntax error
Detailed Streams¶
Aggregate Trade Streams (<symbol>@aggTrade)¶
Push aggregated trade data per taker order.\ - Update speed: real-time
Payload:
[
"aggTrade",
1672515782136,
"BNBBTC",
12345,
"0.001",
"100",
100,
105,
1672515782136,
true,
true
]