User Data Streams for Binance Spot TESTNET(2024-03-13)
General WSS information
- The base API endpoint is: https://testnet.binance.vision/
- A User Data Stream
listenKey
is valid for 60 minutes after creation. - Doing a
PUT
on an activelistenKey
will extend its validity for 60 minutes. - Doing a
DELETE
on an activelistenKey
will close the stream and invalidate thelistenKey
. - Doing a
POST
on an account with an activelistenKey
will return the currently activelistenKey
and extend its validity for 60 minutes. - The base websocket endpoint is: wss://stream.binance.com:9443
- User Data Streams are accessed at /ws/\<listenKey> or /stream?streams=\<listenKey>
- A single connection to stream.binance.com is only valid for 24 hours; expect to be disconnected at the 24 hour mark
API Endpoints
#
Create a listenKey (USER_STREAM)Start a new user data stream. The stream will close after 60 minutes unless a keepalive is sent. If the account has an active listenKey
, that listenKey
will be returned and its validity will be extended for 60 minutes.
Weight: 1
Parameters: NONE
Response:
#
Ping/Keep-alive a listenKey (USER_STREAM)Keepalive a user data stream to prevent a time out. User data streams will close after 60 minutes. It's recommended to send a ping about every 30 minutes.
Weight: 1
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
listenKey | STRING | YES |
Response:
#
Close a listenKey (USER_STREAM)Close out a user data stream.
Weight: 1
Parameters:
Name | Type | Mandatory | Description |
---|---|---|---|
listenKey | STRING | YES |
Response:
Web Socket Payloads
#
Account UpdateoutboundAccountPosition
is sent any time an account balance has changed and contains the assets that were possibly changed by the event that generated the balance change.
#
Balance UpdateBalance Update occurs during the following:
- Deposits or withdrawals from the account
- Transfer of funds between accounts (e.g. Spot to Margin)
Payload
#
Order UpdateOrders are updated with the executionReport
event.
Payload:
Note: Average price can be found by doing Z
divided by z
.
#
Conditional Fields in Execution ReportThese are fields that appear in the payload only if certain conditions are met.
For additional information on these parameters, please refer to the Spot Glossary.
Field | Name | Description | Examples |
---|---|---|---|
d | Trailing Delta | Appears only for trailing stop orders. | "d": 4 |
D | Trailing Time | "D": 1668680518494 | |
j | Strategy Id | Appears only if the strategyId parameter was provided upon order placement. | "j": 1 |
J | Strategy Type | Appears only if the strategyType parameter was provided upon order placement. | "J": 1000000 |
v | Prevented Match Id | Appears only for orders that expired due to STP. | "v": 3 |
A | Prevented Quantity | "A":"3.000000" | |
B | Last Prevented Quantity | "B":"3.000000" | |
u | Trade Group Id | "u":1 | |
U | Counter Order Id | "U":37 | |
Cs | Counter Symbol | "Cs": "BTCUSDT" | |
pl | Prevented Execution Quantity | "pl":"2.123456" | |
pL | Prevented Execution Price | "pL":"0.10000001" | |
pY | Prevented Execution Quote Qty | "pY":"0.21234562" | |
W | Working Time | Appears when the order is working on the book | "W": 1668683798379 |
b | Match Type | Appears for orders that have allocations | "b":"ONE_PARTY_TRADE_REPORT" |
a | Allocation ID | "a":1234 | |
k | Working Floor | Appears for orders that potentially have allocations | "k":"SOR" |
uS | UsedSor | Appears for orders that used SOR | "uS":true |
If it's an order list, an event will be displayed named ListStatus
in addition to the executionReport
event.
Payload
#
Execution typesNEW
- The order has been accepted into the engine.CANCELED
- The order has been canceled by the user.REPLACED
(currently unused)REJECTED
- The order has been rejected and was not processed. (e.g. Cancel Replace orders where the new order placement was rejected even if the cancel request succeeded.)TRADE
- Part of the order or all of the order's quantity has filled.EXPIRED
- The order was canceled according to the order type's rules (e.g. LIMIT FOK orders with no fill, LIMIT IOC or MARKET orders that partially fill) or by the exchange, (e.g. orders canceled during liquidation, orders canceled during maintenance).TRADE_PREVENTION
- The order has expired due to STP.
Check the Rest API Documentation for more relevant enum definitions.
#
Listen Key ExpiredThis event is sent when the listen key expires.
No more events will be sent after this until a new listenKey
is created.
This event will not be pushed when the stream is closed normally.
Payload: