Subscribe Assets
API Description
This Websocket provides real-time updates on asset balances when trading activity occurs on the user's spot account after the connection is established.
Note: Asset data is accessible via both RESTful and Websocket APIs. This page describes the Websocket API. For information on the RESTful API, please click here
Precautions
- The Websocket connection only returns real-time updates for assets affected by orders that enter trading after the connection is established. Updates for pre-existing orders or already executed trades prior to connection will not be pushed. Users should ensure that they have active trading activity to receive real-time updates.
Authentication
This is a private interface and requires authentication. For details on using the RESTful API, please refer to Introduction > Authentication & Code Snippet > Spot > Websocket Private Interface.
Websocket URL
Frequency limit
None
Subscription Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| event | True | String | Subscribe or unsubscribe: sub: subscribe, unsub: unsubscribe. Note: This parameter is case-sensitive. |
| params | True | Json | Data object containing the following: |
| -biz | True | String | Specifies the channel, e.g.,"exchange" |
| -type | True | String | Defines the function type, e.g., "assets" |
Response Parameters
| Parameter | Type | Description |
|---|---|---|
| biz | String | Specifies the channel, e.g.,"exchange" |
| type | String | Defines the function type, e.g., "order" |
| data | Array | Data object |
| -available | Long | Available balance |
| -currency | String | Base currency i.e., BTC |
| -time | String | Timestamp |
| -type | String | Type:change |
| -ledger_id | String | Associated ledger id |
| -account | String | Account:spot |
| -hold | String | Holdings |
Subscription Example
The following Python code shows how to subscribe to users assets.
Note: For a complete code example, please refer to Introduction > Authentication & Code Snippet > Spot > Websocket Private Interface.
url = "wss://ws.futurescw.com"
subscription_payload = {"event": "sub",
"params": {"biz": "exchange",
"type": "assets"}}
api_key= "your_api_key"
sec_key = "your_sec_key"
SpotWebsocketPrivate(url, subscription_payload, api_key, sec_key) # function SpotWebsocketPrivate() is defined in section (Introduction > Authentication & Code Snippet > Spot > Websocket Private Interface)
Note: For a complete Java code example, please refer to Introduction > Authentication & Code Snippet > Spot > Websocket Private Interface.
Response Example
The following is an example response returned by the above Python subscription. The Websocket subscription will keep updating assets balance in real-time. For brevity, only the initial response is shown below:
{'data': {'result': True}, 'channel': 'login'}
{'biz': 'exchange', 'data': {'result': True}, 'channel': 'subscribe', 'type': 'assets'}
{'biz': 'exchange',
'data': {'available': '12.59490035',
'currency': 'USDT',
'time': 1743773396836,
'type': 'change',
'ledger_id': 1125899934698144651,
'account': 'spot',
'hold': '0'},
'type': 'assets'}
{'biz': 'exchange',
'data': {'available': '0.0025',
'currency': 'BTC',
'time': 1743773396836,
'type': 'change',
'ledger_id': 1125899934698144652,
'account': 'spot',
'hold': '0'},
'type': 'assets'}