Skip to main content

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

  1. 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

wss://ws.futurescw.com

Frequency limit

None

Subscription Parameters

ParameterMandatoryTypeDescription
eventTrueStringSubscribe or unsubscribe:
sub: subscribe,
unsub: unsubscribe.
Note: This parameter is case-sensitive.
paramsTrueJsonData object containing the following:
-bizTrueStringSpecifies the channel, e.g.,"exchange"
-typeTrueStringDefines the function type, e.g., "assets"

Response Parameters

ParameterType Description
bizStringSpecifies the channel, e.g.,"exchange"
typeStringDefines the function type, e.g., "order"
dataArrayData object
-availableLongAvailable balance
-currencyStringBase currency i.e., BTC
-timeStringTimestamp
-typeStringType:change
-ledger_idStringAssociated ledger id
-accountStringAccount:spot
-holdStringHoldings

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'}