Balance
{{WSS_SERVER}}/ws/user
Modified at: 8 个月前
Balance is used to subscribe to real-time updates about user's account balances.
Before receiving real-time updates about your account balances through the "mybalance" channel, it's essential to subscribe to Authorize channel.
Update Speed
Real-time
Message Structure
Send Message
- type: Specifies the type of WebSocket message.
- Type: String
- Value: "subscribe"
- channel: Indicates the type of data to subscribe to.
- Type: String
- Value: "mybalance"
- id: A unique identifier for the subscription request.
- Type: String
- Value: A randomly generated string or any unique identifier.
Subscribe Example
{ "type": "subscribe", "channel": "mybalance", "id": "random string" }
Unsubscribe Example
Upon sending a subscribe/unsubscribe message, you will receive a message indicating whether the subscription was successful or if there was an error. Additionally, the response will include the same ID that you included in your subscribe message, allowing you to match the response message to the specific subscribe request.{ "type": "unsubscribe", "channel": "mybalance", "id": "random string" }
Response Example
{
error: false,
id: "0x8f1afa3ed705242859bf1373691d747b96b7d27903f66f7a8ff47872b1677925",
msg: "success"
}
Initial Message
- type: Specifies the type of WebSocket message. For "mybalance" channel, "init" means initialization, and "update" means an update.
- Type: String
- Value: "init"
- channel: Indicates the type of data to subscribe to.
- Type: String
- Value: "mybalance"
- assets: Contains the assets that have changes.
- assetName: The name of the asset(e.g., "USDT", or "WBTC").
- Type: String
- avalibale: The updated available balance of the asset after the event.
- Type: Number
- event: The type of event triggering the balance update.(e.g., INIT")
- Type: String
- inUse: The lowest price reached during the candlestick's duration.
- Type: Number
- assetName: The name of the asset(e.g., "USDT", or "WBTC").
Response Example
{
"type": "init",
"channel": "mybalance",
"assets":
{
"assetName": "USDT",
"available": 18112.267984,
"inUse": 47.562821,
"event": "INIT"
},
{
"assetName": "WBTC",
"available": 18112,
"inUse": 0,
"event": "INIT"
}
}
Update Message
- type: Specifies the type of WebSocket message. For "mybalance" channel, "init" means initialization, and "update" means an update.
- Type: String
- Value: "init"
- channel: Indicates the type of data to subscribe to.
- Type: String
- Value: "mybalance"
- assets: Contains the assets that have changes.
- assetName: The name of the asset(e.g., "USDT", or "WBTC").
- Type: String
- avalibale: The updated available balance of the asset after the event.
- Type: Number
- event: The type of event triggering the balance update.(e.g., "ORDER_MATCH", "DEPOSIT", or "WITHDRAW")
- Type: String
- inUse: The lowest price reached during the candlestick's duration.
- Type: Number
- preAvailable: The available balance of the asset before the event occurred.
- Type: Number
- preInUse: The balance in use or reserved for open orders before the event occurred.
- Type: Number
Update Example
- Type: Number
- assetName: The name of the asset(e.g., "USDT", or "WBTC").
{
"type": "update",
"channel": "mybalance",
"assets":
{
"assetName": "USDT",
"available": 18112.267984,
"inUse": 47.562821,
"event": "ORDER_MATCH",
"preAvailable": 19115.210184,
"preInUse": 138.3458
}
}
请求参数
无
Modified at 8 个月前