Get Internal Account Order History
To use this feature, you must have the API key. Read here to view how to get our API key
Get order history by API key
GET https://api.tronsave.io/v2/orders
Rate limit: 15 requests per 1 second
Get many orders sorted by creation time. Default: return 10 newest orders
Query Parameters
Name
Type
Description
page
Integer
start from 0. Default:0
pageSize
Integer
default: 10
{
"error": false,
"message": "Success",
"data": {
"id": string, // id of order
"requester": string, // the address represents the order owner
"receiver": string, // the address of the resource that is received
"resourceAmount": number, // the amount of resource
"resourceType": string, // the resource type is "ENERGY" or "BANDWIDTH"
"remainAmount": number, // the remaining amount can be matched by the system,
"price": number, // price unit is equal to SUN
"durationSec": number, // rent duration, duration unit is equal to seconds
"orderType": string, // type of order is "NORMAL" or "EXTEND"
"allowPartialFill": boolean, //Allow the order to be filled partially or not
"payoutAmount": number, // Total payout of this order
"fulfilledPercent": number, //The percent that shows filling processing. 0-100
"delegates": [ //All matched delegates for this order
{
"delegator": string, // The address that delegates the resource for the target address
"amount": number, //The amount of resource was delegated
"txid": number // The transaction ID in onchain
}[]
}
}[],
"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("-------------------")Last updated