Skip to main content

Get Coin Exchange Records

Query the coin exchange records.

caution

You may have a long delay of this endpoint.

HTTP Request

GET /private/v1/asset/exchange/list

Request Parameters

ParameterRequiredTypeComments
fromCoinfalsestringThe currency to convert from. e.g,BTC
toCoinfalsestringThe currency to convert to. e.g,USDT
limitfalseintegerLimit for data size per page. [1, 50]. Default: 10
cursorfalsestringCursor. Use the nextPageCursor token from the response to retrieve the next page of the result set

Response Parameters

ParameterTypeComments
nextPageCursorstringRefer to the cursor request parameter
orderBodyarrayObject
> fromCoinstringThe currency to convert from
> fromAmountstringThe amount to convert from
> toCoinstringThe currency to convert to
> toAmountstringThe amount to convert to
> exchangeRatestringExchange rate
> createdTimestringExchange created timestamp (sec)
> exchangeTxIdstringExchange transaction ID

Request Example

import time
import hmac
import hashlib
import requests
import urllib.parse

def create_request(apiKey, secret, params):
url = 'https://openapi-testnet.zoomex.com/private/v1/asset/exchange/list'
timestamp = int(time.time() * 1000)
recv_window = 1000000

params['api_key'] = apiKey
params['timestamp'] = timestamp
params['recv_window'] = recv_window

ordered_params = '&'.join([f"{key}={params[key]}" for key in sorted(params.keys())])

signature = hmac.new(secret.encode('utf-8'), ordered_params.encode('utf-8'), hashlib.sha256).hexdigest()

params['sign'] = signature

headers = {
'X-BAPI-API-KEY': apiKey,
'X-BAPI-SIGN': signature,
'X-BAPI-TIMESTAMP': str(timestamp),
'X-BAPI-RECV-WINDOW': str(recv_window)
}

query_string = urllib.parse.urlencode(params)
full_url = f"{url}?{query_string}"

response = requests.get(full_url, headers=headers)

print("response status:", response.status_code)
print("response info:", response.json())
print("response time:", response.elapsed.total_seconds())

apiKey = 'your key'
secret = 'your secret'
params = {
"fromCoin": "BTC",
"toCoin": "ETH",
}

create_request(apiKey, secret, params)

Response Example

{
"retCode": 0,
"retMsg": "OK",
"result": {
"orderBody": [
{
"fromCoin": "BTC",
"fromAmount": "0.100000000000000000",
"toCoin": "ETH",
"toAmount": "1.385866230000000000",
"exchangeRate": "13.858662380000000000",
"createdTime": "1672197760",
"exchangeTxId": "145102533285208544812654440448"
}
],
"nextPageCursor": "173341:1672197760"
},
"retExtInfo": {},
"time": 1672990464021
}