交易历史
返回您账户自己的交易,最新的在前,支持分页和状态过滤。仅列出 API 密钥所属账户下的交易。余额充值、推荐奖励和提现不属于订单,不会列出。
POST /v1/transactions/history
请求
所有参数都是可选的。如果未指定参数,返回第一页的10个项目。 未知的 status、小于 1 的 page 或超出 1–50 范围的 per_page 将被拒绝,返回代码 2。不是 1–26 个字符字符串的 user_subscription_id 同样会被拒绝。
请求参数
| 字段 | 类型 | 必需 | 描述 |
|---|---|---|---|
| page | integer | 否 | 页码 (默认: 1, 最小值: 1) |
| per_page | integer | 否 | 每页项目数 (默认: 10, 最大值: 50) |
| status | string | 否 | 按交易状态过滤:new、pending、success 或 failed(查看状态列表) |
| user_subscription_id | string | 否 | 仅返回您的某个订阅所购买的交易:即 订阅历史 和 开始订阅 返回的 id。不属于您的订阅的 id 返回空页 |
bash
#!/bin/bash
API_TOKEN="your_api_token"
API_SECRET="your_api_secret"
REQUEST_BODY='{
"page": 1,
"per_page": 10,
"status": "success"
}'
# 计算签名
SIGNATURE=$(echo -n "${REQUEST_BODY}${API_SECRET}" | sha256sum | cut -d' ' -f1)
# 执行 API 请求
curl -X POST "https://api.trxup.com/v1/transactions/history" \
-H "Authorization: Bearer ${API_TOKEN}" \
-H "X-Signature: ${SIGNATURE}" \
-H "Content-Type: application/json" \
-d "${REQUEST_BODY}"javascript
const crypto = require('crypto');
const axios = require('axios');
const apiToken = 'your_api_token';
const apiSecret = 'your_api_secret';
const requestBody = JSON.stringify({
page: 1,
per_page: 10,
status: 'success'
});
// 计算签名
const signature = crypto
.createHash('sha256')
.update(requestBody + apiSecret)
.digest('hex');
// 执行 API 请求
axios({
method: 'post',
url: 'https://api.trxup.com/v1/transactions/history',
headers: {
'Authorization': `Bearer ${apiToken}`,
'X-Signature': signature,
'Content-Type': 'application/json'
},
data: requestBody
})
.then(response => console.log(response.data))
.catch(error => console.error(error));php
<?php
$apiToken = 'your_api_token';
$apiSecret = 'your_api_secret';
$requestBody = json_encode([
'page' => 1,
'per_page' => 10,
'status' => 'success'
]);
// 计算签名
$signature = hash('sha256', $requestBody . $apiSecret);
// 执行 API 请求
$ch = curl_init('https://api.trxup.com/v1/transactions/history');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $requestBody);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer ' . $apiToken,
'X-Signature: ' . $signature,
'Content-Type: application/json'
]);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
?>python
import hashlib
import json
import requests
api_token = 'your_api_token'
api_secret = 'your_api_secret'
request_body = json.dumps({
'page': 1,
'per_page': 10,
'status': 'success'
})
# 计算签名
signature = hashlib.sha256((request_body + api_secret).encode()).hexdigest()
# 执行 API 请求
headers = {
'Authorization': f'Bearer {api_token}',
'X-Signature': signature,
'Content-Type': 'application/json'
}
response = requests.post(
'https://api.trxup.com/v1/transactions/history',
headers=headers,
data=request_body
)
print(response.json())无参数请求示例
bash
#!/bin/bash
API_TOKEN="your_api_token"
API_SECRET="your_api_secret"
REQUEST_BODY='{}'
# 计算签名
SIGNATURE=$(echo -n "${REQUEST_BODY}${API_SECRET}" | sha256sum | cut -d' ' -f1)
# 执行 API 请求
curl -X POST "https://api.trxup.com/v1/transactions/history" \
-H "Authorization: Bearer ${API_TOKEN}" \
-H "X-Signature: ${SIGNATURE}" \
-H "Content-Type: application/json" \
-d "${REQUEST_BODY}"响应
响应包含账户交易的一页数据和分页信息。每个项目的字段与 检查交易状态 对同一 id 返回的字段完全相同。
一次购买多种资源(例如同时购买能量和带宽)的交易算作一个项目,其 amount 为该交易收取的全部金额。其 service 为 "energy",params.amounts 列出所购买的每种资源。
响应字段
| 字段 | 类型 | 描述 |
|---|---|---|
| code | integer | 响应代码 (0 = 成功) |
| request_id | string | 唯一请求标识符 |
| result | object | 响应数据 |
| result.page | integer | 当前页码 |
| result.per_page | integer | 每页项目数 |
| result.total | integer | 符合过滤条件的交易总数 |
| result.items | array | 交易列表,最新的在前 |
| result.items[].id | string | 内部交易ID |
| result.items[].created_at | string | 创建时间戳(ISO 8601格式) |
| result.items[].status | string | 交易状态(查看状态列表) |
| result.items[].external_id | string|null | 外部交易ID(如果提供) |
| result.items[].service | string | 服务类型:"energy"、"bandwidth" 或 "activate_address" |
| result.items[].params | object|null | 原始请求参数 |
| result.items[].amount | string | 交易金额(TRX) |
| result.items[].hash | string|null | 交易哈希;仅当 status 为 success 时存在 |
响应示例
不带参数的请求的响应:
json
{
"code": 0,
"request_id": "64daeda7-15e4-4bcf-ae60-c94867af66d8",
"result": {
"page": 1,
"per_page": 10,
"total": 3,
"items": [
{
"id": "01M52FEER5JVJ16QNSVX75700Q",
"created_at": "2026-10-01T12:02:00+00:00",
"status": "new",
"external_id": null,
"service": "energy",
"params": {
"address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
"amounts": {
"energy": 65000
},
"duration": 1
},
"amount": "3.58"
},
{
"id": "01M52FEEQT9TGZCHG1732ARRDN",
"created_at": "2026-10-01T12:01:00+00:00",
"status": "failed",
"external_id": "hist-energy",
"service": "energy",
"params": {
"address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
"amounts": {
"energy": 65000
},
"duration": 1
},
"amount": "3.58"
},
{
"id": "01M52FEEPEY6V1SBAMCDMA4GTG",
"created_at": "2026-10-01T12:00:00+00:00",
"status": "success",
"external_id": "hist-bundle",
"service": "energy",
"params": {
"address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t",
"amounts": {
"energy": 65000,
"bandwidth": 5000
},
"duration": 1
},
"amount": "3.64",
"hash": "aa11bb22cc33dd44ee55ff6600112233445566778899aabbccddeeff00112233"
}
]
}
}可能的错误
| 错误代码 | Key | 描述 |
|---|---|---|
| 1 | auth | 认证错误 (无效的令牌或签名) |
| 2 | invalid_service_or_params | 无效的服务或参数 |
| 500 | internal_server_error | 服务器内部错误 |