Listen Token User Data Stream
This is the recommended successor to the deprecated listen-key-based User Data Stream on
wss://stream.binance.com:9443. It uses a short-lived listen token and a WebSocket API subscription method, and offers lower latency. See the Change Log for the deprecation announcement.
Connect
- The base REST endpoint is: https://api.binance.com
POST /sapi/v1/userListenTokencreates a new user data stream and returns alistenToken.- Request weight (UID): 1
expirationTime = current time + validity. Default and maximum validity are both 24 hours.isIsolated(BOOLEAN):truemeans isolated margin (thensymbolis required); default is cross margin.- To extend a subscription, call
POST /sapi/v1/userListenTokenagain before the current subscription expires, obtain a newlistenToken, then calluserDataStream.subscribe.listenTokenagain with the new token. The subscription extends seamlessly to the newexpirationTime.
- The base WebSocket API endpoint is:
wss://ws-api.binance.com:443/ws-api/v3- testnet:
wss://ws-api.testnet.binance.vision/ws-api/v3
- testnet:
- Subscribe via the WebSocket API method
userDataStream.subscribe.listenTokenwith the paramlistenToken(string, required).- Request weight: 2
- Non-authenticated sessions are allowed to use this feature.
- An invalid
listenTokenreturns error -1209.
- If a subscription is not extended before its token expires, it expires and an
eventStreamTerminatedevent is sent. No further events will be pushed after that until a new token is created and a new subscription is opened.
HTTP Request — POST /sapi/v1/userListenToken
Request
| Name | Type | Required | Description |
|---|---|---|---|
symbol | STRING | CONDITIONAL | Trading pair symbol; required when isIsolated is true, e.g. BNBUSDT. |
isIsolated | BOOLEAN | NO | Whether it is isolated margin; true means isolated; default is cross margin. |
validity | LONG | NO | Validity in milliseconds; default 24 hours, maximum 24 hours. |
Response Example
Code
WebSocket API Method — userDataStream.subscribe.listenToken
Subscribe to the user data stream using the listenToken obtained from
POST /sapi/v1/userListenToken.
Request Example
Code
Response Example
Code
Event: Event Stream Terminated
Description
This event is sent when the subscription expires because it was not extended before the
listenToken's expirationTime. No more events will be sent after this until a new listenToken
is created and a new subscription is opened.
Event Name
eventStreamTerminated
Payload
Code
Was this page helpful?
Last modified on