Tronsave
🇨🇳 Chinese
🇨🇳 Chinese
  • 📗INTRODUCTION
    • Tronsave是什么?
    • 什么选 Tronsave?
  • Buyer
    • 如何购买能量和带宽?
      • 在网站上购买
      • 如何在Telegram上购买能源
        • 1: 创建Telegram Tronsave帐户
        • 2: 如何存款
        • 3: 获取Tronsave API密钥
        • 4. 如何在 Telegram 上购买
    • 延长
      • 快速延长
      • 提高
  • 🏬Seller
    • 质押 2.0 (Stake 2.0)
    • 权限 (Permission)
    • 出售能量/带宽
      • 设置自动卖出 (Setup Auto Sell)
      • 手动出售
      • 卖出建议
  • 🤝Partner
    • 机器人代理
      • 注册
      • 机器人管理
  • 💻DEVELOPER
    • 获取 API 密钥
      • 在网站上
      • 在Telegram上
    • 购买资源 (v2)
      • 使用签名交易 (Signed tx)
        • 估算TRX
        • 获取已签名交易
        • 创建订单
      • 使用 API 密钥
        • 获取内部账户信息
        • 获取订单簿 (Order book)
        • 获取估算 TRX (Estimate TRX)
        • 购买能源
        • 获取单个订单详情
        • 获取内部账户订单历史
    • 扩展订单 (v2)
      • 步骤 1:获取可扩展的委托人
      • 步骤 2:扩展请求
    • SDK 库
    • REST API v0
      • 通过 REST API 购买
        • 使用签名交易 (Signed tx)
          • 估算TRX
          • 获取已签名交易
          • 创建订单
          • Demo
        • 使用 API 密钥
          • 获取内部账户信息
          • 获取订单簿 (Order book)
          • 获取估算 TRX (Estimate TRX)
          • 购买能源
          • 获取单个订单详情
          • 获取内部账户订单历史
      • 订单延长使用API密钥
  • 💰 Referrer
    • 推荐 (Referral)
  • 💡FAQ
    • 能源市场问题
    • 计算 TronSave 的年化收益率 (APY)
    • 如何在 Tronsave 中连接钱包?
    • 服务团队
  • 👨‍💻Full Code Example
    • Code Example (v2)
      • 使用私钥通过 API 购买能源
      • 使用 API 密钥通过 API 购买能源
      • 使用 API 密钥通过 API 扩展订单
      • 使用私钥通过 API 扩展订单
    • Code Exaample (v0)
      • 使用私钥通过 API 购买能源
      • 使用 API 密钥通过 API 购买能源
      • 使用API密钥通过API延长订单
Powered by GitBook
On this page
  1. DEVELOPER
  2. 购买资源 (v2)
  3. 使用 API 密钥

获取内部账户订单历史

Previous获取单个订单详情Next扩展订单 (v2)

Last updated 5 days ago

要使用此功能,您必须拥有 API 密钥。请阅读以了解如何获取我们的 API 密钥。

通过 API 密钥获取历史

GET https://api.tronsave.io/v2/orders

速率限制 (Rate limit): 每1秒15个请求。

获取许多订单按创建时间排序。默认:返回10个最新订单

Query Parameters

Name
Type
Description

page

Integer

从0开始. Default: 0

pageSize

Integer

Default: 10

{
    "error": false,
    "message": "Success",
    "data": {
        "id": string, // 订单 ID
        "requester": string, // 代表订单所有者的地址
        "receiver": string, // 接收资源的地址
        "resourceAmount": number, // 资源数量
        "resourceType": string, // 资源类型,可以是 "ENERGY" 或 "BANDWIDTH"
        "remainAmount": number, // 系统可以匹配的剩余数量
        "price": number, // 价格,单位为 SUN
        "durationSec": number, // 租赁时长,单位为秒
        "orderType": string, // 订单类型,"NORMAL" 或 "EXTEND"
        "allowPartialFill": boolean, // 是否允许部分匹配
        "payoutAmount": number, // 订单的总支付金额
        "fulfilledPercent": number, // 显示填充进度的百分比,范围 0-100
        "delegates": [ // 所有匹配的委托人
            {
                "delegator": string, // 为目标地址委托资源的地址
                "amount": number, // 委托的资源数量
                "txid": number // 链上交易 ID
            }[]
        ]
    }[],
        "total": number
}

例子 (Example)

{
  "apikey": <YOUR_API_KEY>
}
{
    "error": false,
    "message": "Success",
    "data": {
        "data": [
            {
                "id": "6819c7578729a45600f740d3",
                "requester": "TFwUFWr3QV376677Z8VWXxGUAMFSSSSSS",
                "receiver": "TFwUFWr3QV376677Z8VWXxGUAMFSSSSSS",
                "resourceAmount": 32000,
                "resourceType": "ENERGY",
                "remainAmount": 0,
                "orderType": "NORMAL",
                "price": 90,
                "durationSec": 300,
                "allowPartialFill": false,
                "payoutAmount": 2880000,
                "fulfilledPercent": 100,
                "delegates": [
                    {
                        "delegator": "THnnMCe67VMDXoivepiA7ZQSB8888888",
                        "amount": 32000,
                        "txid": "transaction_id_1"
                    }
                ]
            },
            {
                "id": "68198bcd8729a45600f740cf",
                "requester": "TFwUFWr3QV376677Z8VWXxGUAMFSSSSSS",
                "receiver": "TFwUFWr3QV376677Z8VWXxGUAMFSSSSSS",
                "resourceAmount": 1234,
                "resourceType": "BANDWIDTH",
                "remainAmount": 0,
                "orderType": "NORMAL",
                "price": 600,
                "durationSec": 900,
                "allowPartialFill": false,
                "payoutAmount": 740400,
                "fulfilledPercent": 100,
                "delegates": [
                    {
                        "delegator": "TMhiksDwSVjuxdXLwdNQEJpuFCLG77777",
                        "amount": 1234,
                        "txid": "transaction_id_2"
                    }
                ]
            }
        ],
        "total": 2
    }
}

Example Code

const GetOrderHistory = async (apiKey) => {
    const url = `${TRONSAVE_API_URL}/v2/orders`
    const data = await fetch(url, {
        headers: {
            'apikey': apiKey
        }
    })
    const response = await data.json()
     /**
     * Example response 
        {
            "error": false,
            "message": "Success",
            "data": 
            {
                "total": 2,
                "data": [
                    {
                        "id": "6809b08a14b1cb7c5d195d66",
                        "requester": "TTgMEAhuzPchDAL4pnm2tCNmqXp13AxzAd",
                        "receiver": "TFwUFWr3QV376677Z8VWXxGUAMFSrq1MbM",
                        "resourceAmount": 40000,
                        "resourceType": "ENERGY",
                        "remainAmount": 0,
                        "orderType": "NORMAL",
                        "price": 81.5,
                        "durationSec": 900,
                        "allowPartialFill": false,
                        "payoutAmount": 3260000,
                        "fulfilledPercent": 100,
                        "delegates": [
                            {
                                "delegator": "THnnMCe67VMDXoivepiA7ZQSB8jbgKDodf",
                                "amount": 40000,
                                "txid": "19be98d0183b29575d74999a93154b09b3c7d05051cdbd52c667cd9f0b3cc9b0"
                            }
                        ]
                    },
                    {
                        "id": "6809aaf2e2e17d3c588b467a",
                        "requester": "TTgMEAhuzPchDAL4pnm2tCNmqXp13AxzAd",
                        "receiver": "TFwUFWr3QV376677Z8VWXxGUAMFSrq1MbM",
                        "resourceAmount": 40000,
                        "resourceType": "ENERGY",
                        "remainAmount": 0,
                        "orderType": "NORMAL",
                        "price": 81.5,
                        "durationSec": 900,
                        "allowPartialFill": false,
                        "payoutAmount": 3260000,
                        "fulfilledPercent": 100,
                        "delegates": [
                            {
                                "delegator": "THnnMCe67VMDXoivepiA7ZQSB8jbgKDodf",
                                "amount": 40000,
                                "txid": "447e3fb28ad7580554642d08b9a6b220bc86f667b47edad47f16802594b6b1e3"
                            }
                        ]
                    },
                ]
            }
        }
     */
    return response
}
<?php

/**
 * Get order history from the TRONSAVE API
 * 
 * @param string $apiKey API key for authentication
 * @return array{
 *     error: bool,
 *     message: string,
 *     data: array{
 *         total: int,
 *         data: array<array{
 *             id: string,
 *             requester: string,
 *             receiver: string,
 *             resourceAmount: int,
 *             resourceType: string,
 *             remainAmount: int,
 *             orderType: string,
 *             price: float,
 *             durationSec: int,
 *             allowPartialFill: bool,
 *             payoutAmount: int,
 *             fulfilledPercent: int,
 *             delegates: array<array{
 *                 delegator: string,
 *                 amount: int,
 *                 txid: string
 *             }>
 *         }>
 *     }
 * }
 * @throws Exception If API request fails
 */
function getOrderHistory(string $apiKey): array
{
    $url = TRONSAVE_API_URL . "/v2/orders";
    
    $ch = curl_init();
    curl_setopt_array($ch, [
        CURLOPT_URL => $url,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_HTTPHEADER => [
            'apikey: ' . $apiKey
        ]
    ]);

    $response = curl_exec($ch);
    
    if (curl_errno($ch)) {
        throw new Exception('Curl error: ' . curl_error($ch));
    }
    
    curl_close($ch);
    
    $result = json_decode($response, true);
    
    if (json_last_error() !== JSON_ERROR_NONE) {
        throw new Exception('JSON decode error: ' . json_last_error_msg());
    }
    
    return $result;
}

// Example usage:
try {
    $apiKey = 'your-api-key';
    $orderHistory = getOrderHistory($apiKey);
    
    // Print total orders
    echo "Total orders: " . $orderHistory['data']['total'] . "\n";
    
    // Print each order detail
    foreach ($orderHistory['data']['data'] as $order) {
        echo "Order ID: " . $order['id'] . "\n";
        echo "Resource Amount: " . $order['resourceAmount'] . "\n";
        echo "Resource Type: " . $order['resourceType'] . "\n";
        echo "Price: " . $order['price'] . "\n";
        echo "Fulfilled: " . $order['fulfilledPercent'] . "%\n";
        echo "-------------------\n";
    }
} catch (Exception $e) {
    echo "Error: " . $e->getMessage() . "\n";
}
def get_order_history(api_key: str) -> dict:
    """Get order history from the TRONSAVE API"""
    url = "https://api.tronsave.io/v2/orders"
    response = requests.get(url, headers={'apikey': api_key})
    return response.json()

# Example usage
api_key = 'your-api-key'
result = get_order_history(api_key)

# Print results
if not result.get('error'):
    for order in result['data']['data']:
        print(f"Order ID: {order['id']}")
        print(f"Amount: {order['resourceAmount']}")
        print(f"Price: {order['price']}")
        print(f"Fulfilled: {order['fulfilledPercent']}%")
        print("-------------------")
💻
这里