Subscribe Mega Coupon
API Description
The Websocket provides real-time updates on the Mega Coupon, pushing information only when Mega Coupon is issued or nearing expiration. It delivers key details such as balance, status, validity period, and whether advanced KYC verification is required, aiding in efficient asset management.
For more details on Mega Coupon, refer to https://coinw.zendesk.com/hc/en-us/articles/23111150445977-Introduction-to-Futures-Mega-Coupon
Note: Mega Coupon 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 only pushes updates when Mega Coupon is issued or approaching expiration.
Authentication
This is a private Websocket and requires authentication. For details on using the Websocket API, please refer to Introduction > Authentication & Code Snippet > Futures > Websocket Private Interface.
Websocket URL
Frequency limit
The frequency limit for this subscription is 1 request/2s per user ID.
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 fields: |
| -biz | true | String | Specifies the channel, e.g., "futures". |
| -type | true | String | Defines the function type, e.g., "assets_ag". |
Response Parameters
| Parameter | Type | Description |
|---|---|---|
| biz | String | Specifies the channel, e.g., "futures". |
| type | String | Function type e.g., "assets_ag". |
| result | boolean | Indicates whether the subscription or unsubscription was successful: true, false. |
| channel | String | Specifies the action performed: subscribe or unsubscribe. |
| pairCode | String | Base currency of the instrument, i.e., BTC |
| data | Json | Data object, containing the following fields: |
| -agRecordId | Long | Magnum Gold ID |
| -updateDate | Long | Update time (timestamp) |
| -backAmount | BigDecimal | Overdue amount |
| -currentAmount | BigDecimal | Remaining amount |
| -remark | String | Remark |
| -userId | Long | User ID |
| -totalAmount | BigDecimal | Total amount of Mega Coupon |
| -createdDate | Long | Creation time (timestamp) |
| -kyc | Integer | Advanced KYC requirement: 1: yes, 0: no |
| -assetsOut | BigDecimal | Whether the transferred assets are invalid: 1: yes, 0: no |
| -startTime | Long | Validity start time (timestamp) |
| -endTime | Long | Validity expiration date (timestamp) |
| -status | Integer | Status: 0: Pending, 1: Unused, 2: Used, 3: Expired, 4: Issuance failed |
Subscription Example
The following Python code shows how to subscribe to Mega Coupon using Websocket.
Note: For a complete code example, please refer to Introduction > Authentication & Code Snippet > Futures > Websocket Private Interface.
url = "wss://ws.futurescw.com/perpum"
subscription_payload = {"event": "sub",
"params": {"biz": "futures",
"type": "assets_ag"}}
api_key= "your_api_key"
sec_key = "your_sec_key"
FuturesWebsocketPrivate(url, api_key, sec_key, subscription_payload) # function FuturesWebsocketPrivate() is defined in section (Introduction > Authentication & Code Snippet > Futures > Websocket Private Interface)
Note: For a complete Java code example, please refer to Introduction > Authentication & Code Snippet > Futures > Websocket Private Interface.
Response Example
The following is an example response returned by the above Python subscription, it keeps updatating in real-time:
{'event': 'sub', 'params': {'biz': 'futures', 'type': 'assets_ag'}}
{'biz': 'futures',
'data': [{'agRecordId': 475,
'updateDate': 1713192123887,
'backAmount': 0,
'currentAmount': 11,
'remark': '',
'userId': 600001274,
'totalAmount': 11,
'createdDate': 1713192123887,
'kyc': 1,
'assetsOut': 1,
'startTime': 1713192110000,
'endTime': 1713278512000,
'status': 1}],
'type': 'assets_ag'}.........