Websocket Market Streams
- The connection method for Websocket is:
- Base Url: wss://fstream.binance.com
- Three routed endpoints are available based on data type:
- Public (high-frequency public market data):
wss://fstream.binance.com/public - Market (regular market data):
wss://fstream.binance.com/market - Private (user data):
wss://fstream.binance.com/private
- Public (high-frequency public market data):
- Two access modes are supported:
wsmode: streams are composed in the URL path — /ws/<streamName>streammode: streams are passed via query parameters — /stream?streams=<streamName1>/<streamName2>/<streamName3>
- Examples:
wss://fstream.binance.com/market/ws/bnbusdt@aggTradewss://fstream.binance.com/public/ws/bnbusdt@depth/ethusdt@depthwss://fstream.binance.com/market/stream?streams=bnbusdt@aggTrade/btcusdt@markPrice
Important: Connections that do not include a routed path (
/public,/market, or/private) will only receive data from the Public endpoint. Streams belonging to/marketor/privatewill not push data on unrouted connections. For example,wss://fstream.binance.com/ws/btcusdt@depthwill continue to work (since@depthbelongs to/public), butwss://fstream.binance.com/ws/btcusdt@markPricewill not (since@markPricebelongs to/market). See Important WebSocket Change Notice for the full stream-to-endpoint mapping and migration details.
- Combined stream events are wrapped as follows: {"stream":"<streamName>","data":<rawPayload>}
- All symbols for streams are lowercase
- A single connection is only valid for 24 hours; expect to be disconnected at the 24 hour mark
- The websocket server will send a
ping frameevery 3 minutes. If the websocket server does not receive apong frameback from the connection within a 10 minute period, the connection will be disconnected. Unsolicitedpong framesare allowed(the client can send pong frames at a frequency higher than every 15 minutes to maintain the connection). - WebSocket connections have a limit of 10 incoming messages per second.
- A connection that goes beyond the limit will be disconnected; IPs that are repeatedly disconnected may be banned.
- A single connection can listen to a maximum of 1024 streams.
- Considering the possible data latency from RESTful endpoints during an extremely volatile market, it is highly recommended to get the order status, position, etc from the Websocket user data stream.