Account
开发中Account is used to subscribe to real-time updates about user's account changes.
Before receiving real-time updates about your account changes through the "myaccount" 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: "myaccount"
- id: A unique identifier for the subscription request.
- Type: String
- Value: A randomly generated string or any unique identifier.
Subscribe Example
{ "type": "subscribe", "channel": "myaccount", "id": "random string" }
Unsubscribe Example
{ "type": "unsubscribe", "channel": "myaccount", "id": "random string" }
Response Message
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.Response Example
{
error: false,
id: "0x8f1afa3ed705242859bf1373691d747b96b7d27903f66f7a8ff47872b1677925",
msg: "success"
}
Initial Message
Initial response includes information about account details, assets, open orders, deposits, and withdrawals.
- 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: "myaccount"
- timestamp: Specifies the timestamp of the channel is subscribed.
- Type: Integer (UNIX timestamp in milliseconds & UTC)
- Example: 1705642544624
- account: Contains the information of this user.
- vesselApiKey: An array containing the vessel API keys associated with the user's account.
- Type: Array
- vesselPublicKey: The public key associated with the user's vessel.
- Type: String
- vesselApiKey: An array containing the vessel API keys associated with the user's account.
- assets: An array containing information about the user's assets.
- assetName: The name of the asset(e.g., "USDT", or "WBTC").
- Type: String
- avalibale: The initial available balance of the asset.
- Type: Number
- inUse: The balance in use or reserved for open orders before the event occurred.
- Type: Number
- assetName: The name of the asset(e.g., "USDT", or "WBTC").
- openOrders: An array containing details of open orders.
- clientOrderId: The client-assigned unique identifier for the order.
- Type: String
- cumulativeQuoteQty: The updated available balance of the asset after the event.
- Type: Number
- executedQty: The quantity of the order that has been executed.
- Type: Number
- orderId: The unique identifier for the order.
- Type: Number
- orderTime: The timestamp when the order was placed.
- Type: Timestamp
- origQty: The original quantity specified in the order.
- Type: Number
- price: The price specified in the order.
- Type: Number
- side: The side of the order (BUY or SELL).
- Type: String
- status: The current status of the order (NEW, PARTIALLY_FILLED, FILLED, CANCELED, REJECTED, EXPIRED).
- Type: String
- symbol: The trading pair symbol.
- Type: String
- timeInForce: The time in force for the order (GTC, FOK, IOC).
- Type: String
- workingTime: The timestamp when the order last processing.
- Type: Integer (UNIX timestamp in milliseconds & UTC)
- clientOrderId: The client-assigned unique identifier for the order.
Response Example
{
"type": "init",
"channel": "myaccount",
"timestamp": 1705642544624,
"account": {
"vesselApiKey": [
"0x97cb025549d36946fe5a401454a437c0"
],
"vesselPublicKey": "0x97fe66c8bbb312f5142a94b95f667a558cee0cee5aa8ccbcacda33f78c1df05ee38883b9a4b540796b455af78a2645e121ed6efa4ee9be202c1c0f4a3ee155c0"
},
"assets": [
{
"assetName": "USDT",
"available": 178015.2017284,
"inUse": 0
},
{
"assetName": "WBTC",
"available": 1.0662668,
"inUse": 0
}
],
"openOrders": [
{
"clientOrderId": "1705646214930",
"cumulativeQuoteQty": 0,
"executedQty": 0,
"orderId": 428898,
"orderTime": 1705646216401,
"origQty": 0.1335,
"price": 40000,
"side": "BUY",
"status": "NEW",
"symbol": "WBTCUSDT",
"timeInForce": "GTC",
"workingTime": 1705646216401
}
],
"deposits": [
{
"address": "0xdb456c895f91c8a098b22eb0aae1ba7d85c5ae96",
"amount": 100000,
"assetName": "USDT",
"id": 343,
"status": 0,
"timestamp": 1705575360569,
"transactionFee": 0
}
],
"withdraws": [
{
"address": "0xdb456c895f91c8a098b22eb0aae1ba7d85c5ae96",
"amount": 1000,
"assetName": "USDT",
"globalEventId": 17566,
"id": 345,
"status": 0,
"timestamp": 1705575570803,
"transactionFee": 0,
"withdrawOrderId": "1705575570799"
}
]
}
Update Message
This channel delivers real-time update messages triggered by five key events: order match, place order, cancel order, deposit, and withdraw.
Event Types
- ORDER_MATCH: Indicates when an order has been matched with another in the market.
- PLACE_ORDER: Triggered when a user places a new order.
- CANCEL_ORDER: Indicates the cancellation of an existing order.
- DEPOSIT: Occurs when a user initiates a deposit to their account.
- WITHDRAW: Indicates a withdrawal request from the user's account.
Place Order & Cancel Order Event
The meassge of "PLACE_ORDER" and "CANCEL_ORDER" include information about the newly placed or canceled order, its status, and the impact on the user's asset balances.
- type: Specifies the type of WebSocket message. For "mybalance" channel, "init" means initialization, and "update" means an update.
- Type: String
- Value: "update"
- channel: Indicates the type of data to subscribe to.
- Type: String
- Value: "myaccount"
- timestamp: Specifies the timestamp of the channel is subscribed.
- Type: Integer (UNIX timestamp in milliseconds & UTC)
- Example: 1705642544624
- event: Specifies the type of event that triggered the update message
- Type: String
- Value: "PLACE_ORDER" or "CANCEL_ORDER"
- assets: An array containing information about the user's assets that changed due to the "PLACE_ORDER" or "CANCEL_ORDER" event.
- 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
- inUse: The balance in use or reserved for open orders after the event.
- 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
- assetName: The name of the asset(e.g., "USDT", or "WBTC").
- orders: An array containing details of the newly placed or canceled order.
- clientOrderId: The client-assigned unique identifier for the order.
- Type: String
- cumulativeQuoteQty: The updated available balance of the asset after the event.
- Type: Number
- executedQty: The quantity of the order that has been executed.
- Type: Number
- orderId: The unique identifier for the order.
- Type: Number
- orderTime: The timestamp when the order was placed.
- Type: Timestamp
- origQty: The original quantity specified in the order.
- Type: Number
- price: The price specified in the order.
- Type: Number
- side: The side of the order (BUY or SELL).
- Type: String
- status: The current status of the order (NEW, PARTIALLY_FILLED, FILLED, CANCELED, REJECTED, EXPIRED).
- Type: String
- symbol: The trading pair symbol.
- Type: String
- timeInForce: The time in force for the order (GTC, FOK, IOC).
- Type: String
- workingTime: The timestamp when the order last processing.
- Type: Timestamp
Place Order Example
- Type: Timestamp
- clientOrderId: The client-assigned unique identifier for the order.
{
"type": "update",
"channel": "myaccount",
"timestamp": 1705646819864,
"event": "PLACE_ORDER",
"assets": [
{
"assetName": "USDT",
"available": 164475.2017284,
"inUse": 13540,
"preAvailable": 172675.2017284,
"preInUse": 5340
}
],
"orders": [
{
"clientOrderId": "1705646818392",
"cumulativeQuoteQty": 0,
"executedQty": 0,
"orderId": 429501,
"orderTime": 1705646819822,
"origQty": 0.2,
"price": 41000,
"side": "BUY",
"status": "NEW",
"symbol": "WBTCUSDT",
"timeInForce": "GTC",
"workingTime": 1705646819823
}
]
}
Cancel Order Example
{
"type": "update",
"channel": "myaccount",
"timestamp": 1705663061204,
"event": "CANCEL_ORDER",
"assets": [
{
"assetName": "USDT",
"available": 173950.9137284,
"inUse": 8200,
"preAvailable": 168610.9137284,
"preInUse": 13540
}
],
"orders": [
{
"clientOrderId": "1705646214930",
"cumulativeQuoteQty": 0,
"executedQty": 0,
"orderId": 428898,
"orderTime": 1705646216401,
"origQty": 0.1335,
"price": 40000,
"side": "BUY",
"status": "CANCELED",
"symbol": "WBTCUSDT",
"timeInForce": "GTC",
"workingTime": 1705663061200
}
]
}
Order Match Event
The meassge of "PLACE_ORDER" includes details about the assets affected by the order match, executed orders, and relevant trade information.
- type: Specifies the type of WebSocket message. For "mybalance" channel, "init" means initialization, and "update" means an update.
- Type: String
- Value: "update"
- channel: Indicates the type of data to subscribe to.
- Type: String
- Value: "myaccount"
- timestamp: Specifies the timestamp of the channel is subscribed.
- Type: Integer (UNIX timestamp in milliseconds)
- Example: 1705642544624
- event: Specifies the type of event that triggered the update message
- Type: String
- Value: "ORDER_MATCH"
- assets: An array containing information about the user's assets that changed due to the order match event.
- 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
- inUse: The balance in use or reserved for open orders after the event.
- 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
- assetName: The name of the asset(e.g., "USDT", or "WBTC").
- orders: An array containing details of the matched order.
- clientOrderId: The client-assigned unique identifier for the order.
- Type: String
- cumulativeQuoteQty: The updated available balance of the asset after the event.
- Type: Number
- executedQty: The quantity of the order that has been executed.
- Type: Number
- orderId: The unique identifier for the order.
- Type: Number
- orderTime: The timestamp when the order was placed.
- Type: Timestamp
- origQty: The original quantity specified in the order.
- Type: Number
- price: The price specified in the order.
- Type: Number
- side: The side of the order (BUY or SELL).
- Type: String
- status: The current status of the order (NEW, PARTIALLY_FILLED, FILLED, CANCELED, REJECTED, EXPIRED).
- Type: String
- symbol: The trading pair symbol.
- Type: String
- timeInForce: The time in force for the order (GTC, FOK, IOC).
- Type: String
- workingTime: The timestamp when the order last processing.
- Type: Integer (UNIX timestamp in milliseconds & UTC)
- clientOrderId: The client-assigned unique identifier for the order.
- trades: An array containing details of the executed trade.
- fee: The fee incurred for the trade.
- Type: Number
- feeCurrency: The currency in which the fee is calculated.
- Type: String
- isBuyerMaker: Indicates whether the buyer is the maker.
- Type: Boolean
- isMaker: Indicates whether the user is the maker.
- Type: Boolean
- price: The price at which the trade occurred.
- Type: Number
- qty: The quantity of the base token traded.
- Type: Number
- quoteQty: The quantity of the quote token traded.
- Type: Number
- side: The side of the order (BUY or SELL).
- Type: String
- symbol: The trading pair symbol.
- Type: String
- time: The timestamp when the trade occurred.
- Type: Integer (UNIX timestamp in milliseconds & UTC)
Order Match Example
- Type: Integer (UNIX timestamp in milliseconds & UTC)
- fee: The fee incurred for the trade.
{
"type": "update",
"channel": "myaccount",
"timestamp": 1705661521632,
"event": "ORDER_MATCH",
"assets": [
{
"assetName": "USDT",
"available": 168610.9137284,
"inUse": 13540,
"preAvailable": 164475.2017284,
"preInUse": 13540
},
{
"assetName": "WBTC",
"available": 197.9662668,
"inUse": 0,
"preAvailable": 198.0662668,
"preInUse": 0.1
}
],
"orders": [
{
"clientOrderId": "1705661500020",
"cumulativeQuoteQty": 4144,
"executedQty": 0.1,
"orderId": 445788,
"orderTime": 1705661501273,
"origQty": 0.1,
"price": 41440,
"side": "SELL",
"status": "FILLED",
"symbol": "WBTCUSDT",
"timeInForce": "GTC",
"workingTime": 1705661521612
}
],
"trades": [
{
"fee": 8.288,
"feeCurrency": "USDT",
"isBuyerMaker": false,
"isMaker": true,
"price": 41440,
"qty": 0.1,
"quoteQty": 4144,
"side": "SELL",
"symbol": "WBTCUSDT",
"time": 1705661521612
}
]
}
Deposit & Withdraw Event
The meassge of "DEPOSIT" and "WITHDRAW" include information about the deposited or withdrawn assets, associated transactions.
- type: Specifies the type of WebSocket message. For "mybalance" channel, "init" means initialization, and "update" means an update.
- Type: String
- Value: "update"
- channel: Indicates the type of data to subscribe to.
- Type: String
- Value: "myaccount"
- timestamp: Specifies the timestamp of the channel is subscribed.
- Type: Integer (UNIX timestamp in milliseconds & UTC)
- Example: 1705642544624
- event: Specifies the type of event that triggered the update message
- Type: String
- Value: "DEPOSIT" or "WITHDRAW"
- assets: An array containing information about the user's assets that changed due to the "DEPOSIT" or "WITHDRAW" event.
- 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
- inUse: The balance in use or reserved for open orders after the event.
- 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
- assetName: The name of the asset(e.g., "USDT", or "WBTC").
- deposits: An array containing details of the deposited amount.
- address: The address to which the deposit was made.
- Type: String
- amount: The quantity of the deposited asset.
- Type: Number
- assetName: The name of the deposited asset.
- Type: String
- id: The unique identifier for the deposit.
- Type: Number
- status: The current status of the deposit (0 for SUCCESS, 1 for PENDING, 2 for FAILED).
- Type: Number
- timestamp: The timestamp when the deposit occurred.
- Type: Integer (UNIX timestamp in milliseconds & UTC)
- transactionFee: The transaction fee on our platform associated with the deposit.
- Type: Number
- address: The address to which the deposit was made.
- withdraws: An array containing details of the withdrawn amount.
- address: The address to which the withdrawal was made.
- Type: String
- amount: The quantity of the withdrawn asset.
- Type: Number
- assetName: The name of the withdrawn asset.
- Type: String
- globalEventId: The global identifier for the withdrawal event on the blockchain. This ID can be used to check the on-chain status of the withdrawal.
- Type: String
- id: The unique identifier for the deposit.
- Type: Number
- status: The current status of the deposit (0 for SUCCESS, 1 for PENDING, 2 for FAILED).
- Type: Number
- timestamp: The timestamp when the deposit occurred.
- Type: Integer (UNIX timestamp in milliseconds & UTC)
- transactionFee: The transaction fee on our platform associated with the deposit.
- Type: Number
- withdrawOrderId: The client-assigned unique identifier for the withdrawal.
- Type: String
- address: The address to which the withdrawal was made.
Deposit Example
{
"type": "update",
"channel": "myaccount",
"timestamp": 1705663300080,
"event": "DEPOSIT",
"assets": [
{
"assetName": "USDT",
"available": 273950.9137284,
"inUse": 8200,
"preAvailable": 173950.9137284,
"preInUse": 13540
}
],
"deposits": [
{
"address": "0xdb456c895f91c8a098b22eb0aae1ba7d85c5ae96",
"amount": 100000,
"assetName": "USDT",
"id": 414,
"status": 0,
"timestamp": 1705663280028,
"transactionFee": 0
}
]
}
Withdrawal Example
{
"type": "update",
"channel": "myaccount",
"timestamp": 1705664185436,
"event": "WITHDRAW",
"assets": [
{
"assetName": "USDT",
"available": 272951.9137284,
"inUse": 8200,
"preAvailable": 273950.9137284,
"preInUse": 8200
}
],
"withdraws": [
{
"address": "0xdb456c895f91c8a098b22eb0aae1ba7d85c5ae96",
"amount": 999,
"assetName": "USDT",
"globalEventId": 23420,
"id": 416,
"status": 1,
"timestamp": 1705664184261,
"transactionFee": 0,
"withdrawOrderId": "1705664184259"
}
]
}