Get Historical Orders
API Description
This interface allows users to retrieve historical orders across all instruments. It supports optional filtering by a specific instrument and returns up to 100 records per request. Users can further refine the results using time-based filters or pagination for efficient data retrieval.
Note: Historical Orders data is only available via RESTful API.
Precautions
- A maximum of 100 records is returned per request.
- The "orderType" will be returned as "LIMIT" for market orders.
- Orders which did not commence trading will not show up in this interface. Only orders that have been completed will be returned.
Authentication
This is a private interface and requires authentication. For details on using the RESTful API, refer to General Information > Authentication and Code Snippet > Spot > RESTful Private Interface.
Request Method
POST
Endpoint
/api/v1/private?command=getUserTrades
Frequency Limit
The frequency limit for this interface is 10 requests/2s per user ID. In addition to this per-interface limit, a global rate limit is also enforced.
For detailed information on Global rate limits and API Rate Limiting Policy, please refer to the "Frequency Limit" section at click here
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| symbol | False | String | Trading instrument, i.e., BTC_USDT |
| startAt | False | Long | Start time (timestamp) |
| endAt | False | Long | End time (timestamp) |
| limit | False | Integer | Query number: The value of limit ranges from 0 to 100 |
| before | False | String | Pagination parameter for previous page (if any) |
| after | False | String | Pagination parameter for next page (if any) |
Response Parameters
| Parameter | Type | Description |
|---|---|---|
| tradeId | Long | Trade ID |
| orderId | Long | Order ID |
| price | string | Order price in quote currency |
| size | String | Order size in base currency |
| side | String | Trade direction: Buy/Sell |
| orderType | String | Order type:Limit |
| time | Long | Transaction time (timestamp) |
| fee | String | Handling fee |
| before | Long | Pagination parameter for previous page (if any) |
| after | Long | Pagination parameter for next page (if any) |
Request Example
The following Python code shows how to get users historical orders for BTC_USDT.
Note: For a complete code example, please refer to Introduction > Authentication & Code Snippet > Spot > RESTful Private Interface.
api_url = "/api/v1/private?command=getUserTrades"
method = "post"
params = {"symbol": "BTC_USDT",
# "startAt":"1631526172583",
# "endAt":"1631526317779",
}
SpotRestfulPrivate(host, api_url, method, api_key, params, secret_key) # function SpotRestfulPrivate() is defined in section (Introduction > Authentication & Code Snippet > Spot > RESTful Private Interface)
Note: For a complete Java code example, please refer to Introduction > Authentication & Code Snippet > Spot > RESTful Private Interface.
Response Example
The following is an example response returned by the above Python request. For brevity, only one order data is shown below**:**
{'code': '200',
'data': {'list': [{'orderType': 'LIMIT',
'orderId': 4624385377802383167,
'fee': '0E-18',
'price': '82429.080000000000000000',
'size': '0.001200000000000000',
'side': 'BUY',
'time': 1741772251663,
'tradeId': 127204554},.......]},
'msg': 'SUCCESS',
'success': True,
'failed': False}