Private user data stream¶
Required Type: Spot trade (Read only OK)
Create a listenKey via REST, connect to the private WebSocket, then send an authentication message. Events below are top-level JSON objects; use field e to distinguish the event type.
listenKey REST¶
| Purpose | Method | Path | Auth |
|---|---|---|---|
| Create | POST |
/openapi/v1/userDataStream |
API key only (no signature) |
| Keepalive | POST |
/openapi/v1/userDataStream/update?listenKey=... |
API key only |
| Close | POST |
/openapi/v1/userDataStream/close?listenKey=... |
API key only |
Keepalive: call update at least every 30 minutes. After expiry, create a new listenKey and authenticate again.
Connect + authentication¶
- Create a
listenKeyvia REST. - Open WebSocket (no credential in the URL):
Replace <websocket-host> with the WebSocket host for your environment — see Base URLs. (Also accepted: /openapi/ws — defaults to spot.)
- Immediately send an authentication message:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
op |
string | Yes | Must be auth. |
|
listenKey |
string | Yes | Key from POST /openapi/v1/userDataStream. A missing, invalid, or expired key returns code 401 and closes the connection. |
- On success the gateway auto-subscribes your private channel — no
SUBSCRIBErequired.
Success reply (e = auth):
Failure (same shape, then the connection is closed):
Events¶
Each event is a top-level JSON object; field e selects the type. Amounts are decimal strings; trailing zeros may be omitted.
Order / fill¶
Event: executionReport
Emitted for order accepts, cancels, and fills on the private channel.
{
"e": "executionReport",
"E": 1713100000123,
"s": "BTCUSDT",
"c": "my-order-id",
"S": "BUY",
"o": "LIMIT",
"f": "GTC",
"q": "1",
"p": "0.1026441",
"x": "NEW",
"X": "NEW",
"i": 4293153,
"l": "0",
"L": "0",
"z": "0",
"Z": "0",
"n": "0",
"N": "USDT",
"T": 1713100000000,
"t": 0,
"m": false
}
| Field | Type | Meaning |
|---|---|---|
e |
string | Always executionReport |
E |
long | Event time (ms) |
s |
string | Symbol — concatenated base+quote with no separator (e.g. BTCUSDT, CTCAUD), same as REST / exchangeInfo.symbol |
c |
string | Client order ID |
S |
string | Side — see enums |
o |
string | Order type — see enums |
f |
string | Time in force — see enums |
q |
string | Order quantity |
p |
string | Order price |
x |
string | Exec type — see enums |
X |
string | Order status — see enums |
i |
long | Order ID |
l |
string | Last fill qty |
L |
string | Last fill price |
z |
string | Cumulative filled qty |
Z |
string | Cumulative filled quote amount |
n |
string | Commission amount |
N |
string | Commission asset |
T |
long | Trade / transact time (ms) |
t |
long | Trade / exec ID |
m |
boolean | Maker side on this exec |
This event has no stop/trigger price field. REST stopPrice appears only on HTTP responses (number or null); it is not pushed on this stream.
Account Update¶
Event: outboundAccountPosition
Sent any time an account balance changes, and contains only the assets that may have changed. Not sent for snapshot recovery.
{
"e": "outboundAccountPosition",
"E": 1713100000456,
"u": 1713100000000,
"B": [
{ "a": "USDT", "f": "1500000", "l": "136371.2" }
]
}
| Field | Meaning |
|---|---|
e |
Always outboundAccountPosition |
E |
Event Time: the time the event is sent (ms) |
u |
Time of last account update (ms) |
B[].a |
Asset |
B[].f |
Free: available balance |
B[].l |
Locked: held by open orders, plus funds frozen for withdrawals and transfers |
f + l equals the total balance of the asset, the same as free / locked in REST GET /openapi/v1/account.
Non-trade balance delta¶
Event: balanceUpdate
Emitted for non-trade balance changes (deposit, withdraw, transfer, and similar). One event per asset.
{
"e": "balanceUpdate",
"E": 1713100000789,
"a": "USDT",
"d": "100.5",
"T": 1713100000000,
"BS": "CHAIN_DEPOSIT"
}
| Field | Meaning |
|---|---|
e |
Always balanceUpdate |
E |
Event time (ms) |
a |
Asset |
d |
Delta (signed string) |
T |
Clear / transact time (ms) |
BS |
Business subject — see enums |
Enums (wire values)¶
Values below may appear on the private stream. Whether REST accepts them when placing an order is governed by exchangeInfo and the place-order API — not by this list alone.
S — side¶
BUY · SELL
o — order type¶
LIMIT · MARKET · STOP_LOSS · STOP_LOSS_LIMIT · TAKE_PROFIT · TAKE_PROFIT_LIMIT
f — time in force¶
GTC · FOK · IOC
x — exec type¶
NEW · CANCELED · EXPIRED · TRADE · E_CALCULATED · E_SNAPSHOT
X — order status¶
NEW · PARTIALLY_FILLED · FILLED · PARTIALLY_CANCELED · CANCELED · REJECTED · EXPIRED
BS — balance business subject¶
BS |
Meaning |
|---|---|
CHAIN_DEPOSIT |
Deposit (on-chain or fiat); use REST ledger APIs for finer detail |
CHAIN_WITHDRAWAL |
On-chain withdrawal |
CONVERT |
Convert-related balance change |
OTHERS |
Any other balance change |