劃轉 (單帳號內)
創建單帳號下帳戶類型間的劃轉操作
提示
- 每個帳戶類型有其可接受的幣種限制, 比如, 你無法將USDC從
SPOT
劃轉至CONTRACT
。詳情請參考可劃轉幣種接口. - 資金賬戶轉出目前僅支持加密貨幣,不支持法定貨幣.
API頻率: 1次/秒
HTTP 請求
POST /private/v1/asset/transfer/single-account-transfer
請求參數
參數 | 是否必需 | 類型 | 說明 |
---|---|---|---|
requestId | true | string | UUID. 請自行手動生成UUID |
coin | true | string | 幣種 |
amount | true | string | 劃入數量 |
fromAccountType | true | string | 轉出賬戶類型 |
toAccountType | true | string | 轉入賬戶類型 |
響應參數
參數 | 類型 | 說明 |
---|---|---|
transferId | string | UUID |
請求示例
import time
import hmac
import hashlib
import uuid
import requests
import json
def create_transfer_request(apiKey, secret, body):
url = 'https://openapi-testnet.zoomex.com/private/v1/asset/transfer/single-account-transfer'
timestamp = int(time.time() * 1000)
recv_window = 1000000
body['api_key'] = apiKey
body['timestamp'] = timestamp
body['recv_window'] = recv_window
ordered_params = '&'.join([f"{key}={body[key]}" for key in sorted(body.keys())])
signature = hmac.new(secret.encode('utf-8'), ordered_params.encode('utf-8'), hashlib.sha256).hexdigest()
body['sign'] = signature
headers = {
'X-BAPI-API-KEY': apiKey,
'X-BAPI-SIGN': signature,
'X-BAPI-TIMESTAMP': str(timestamp),
'X-BAPI-RECV-WINDOW': str(recv_window),
'Content-Type': 'application/json'
}
response = requests.post(url, headers=headers, data=json.dumps(body))
print("响应状态:", response.status_code)
print("响应信息:", response.json())
print("响应时间:", response.elapsed.total_seconds())
apiKey = 'your key'
secret = 'your secret'
transferId = uuid.uuid4().hex
body = {
"requestId":transferId,
"coin":"USDT",
"amount":"1",
"fromAccountType":"CONTRACT",
"toAccountType":"SPOT",
}
create_transfer_request(apiKey, secret, body)
響應示例
{
"ret_code": 0,
"ret_msg": "OK",
"ext_code": "",
"result": {
"transfer_id": "87c18caa-539a-449e-99cc-c39e4329bcc5"
},
"ext_info": null,
"time_now": 1721037889588
}