Subscribe Current Orders
API Description
This Websocket allows users to subscribe to real-time updates for all current orders, including both market and limit orders.
Note: Current orders data is accessible via both RESTful and Websocket APIs. This page describes the Websocket API. For information on the RRESTful API, please click here
Precautions
- The Websocket connection does not return any response unless new orders are placed or there is a change in order status. If no changes occur, the Websocket will not provide updates. Users should ensure that they have active trading activity to receive real-time updates.
- For market orders, the "side" parameter in the response will return an empty string.
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., "order" |
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 |
| -fee | String | Handling fee |
| -dealFunds | String | Order amount |
| -type | String | Order success:Done |
| -time | Long | Order time (timestamp) |
| -product_id | String | Instrument, i.e., BTC-USDT |
| -order_id | String | Order ID |
| -client_id | String | A custom order ID assigned by the user |
| -size | String | Order size in base currency |
| -remaining_size | String | Remaining order size in base currency |
| -price | String | Order price specified by user:Note: For market orders, it represents the market price. |
| -side | String | Trade direction: BUY/SELL |
| -order_type | String | Order type: LIMIT - limit price, MARKET - market price |
| -reason | String | Reason:Cancelled/Filled |
| -dealAvgPrice | String | Average price |
Subscription Example
The following Python code shows how to subscribe to the current orders.
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": "order"}}
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 he current orders in real-time. For brevity, only the one order information is provided below:
{'data': {'result': True}, 'channel': 'login'}
{'biz': 'exchange', 'data': {'result': True}, 'channel': 'subscribe', 'type': 'order'}
{'biz': 'exchange',
'data': {'side': 'BUY',
'fee': '0',
'dealFunds': '0',
'type': 'RECEIVED',
'client_id': 'you*******',
'remaining_size': '0.0001',
'size': '0.0001',
'price': '82000',
'product_id': 'BTC_USDT',
'time': 1743244437255,
'order_id': 4624530513294751114,
'order_type': 'LIMIT'},
'type': 'order'},.....