Step 1: Get Extendable Delegates
Buy with API Key (Postman)
Check all extendable delegates
POST
https://api.tronsave.io/v2/get-extendable-delegates
Rate limit: 1 request per 1 second
Headers
Name
Type
Description
apikey
String
Tronsave api key that present for internal account.
Request Body
Name
Type
Description
extendTo*
String
Time in milliseconds you want to extend to
receiver*
String
The address that received resource delegate
requester
String
The address of the requester.. If not provided, the requester is taken from the API key.
resourceType
String
"ENERGY" or "BANDWIDTH", default: "ENERGY"
maxPriceAccepted
Number
Number maximum price you want to pay to extend
{
"extend_order_book": [
{
"price": 133,
"value": 64319
},
...
], //Overview extend energy amount at every single price
"total_delegate_amount": 64319,
//Total current delegate of receiver address in tronsave
"total_available_extend_amount": 64319,
//Total available delegate of the receiver address in tronsave
"total_estimate_trx": 8554427,
//Estimate TRX payout if using extend_data below to create extend request
"your_balance": 20000000,
//api key's internal balance
"is_able_to_extend": true,
//Compare balance internal and total_estimate_trx
"extend_data": [
{
"delegator": "TMN2uTdy6rQYaTm4A5g732kHRf72222222",
"is_extend": true,
"extra_amount": 0,
"extend_to": 1728459019
}
]
//extend_data that is used to create Extend requests in Step 2
}
{
"MISSING_PARAMS": "Missing some params in body",
"INVALID_PARAMS": "Some params are invalid"
}
{
"API_KEY_REQUIRED": "Missing api key in headers",
"INVALID_API_KEY": "api key not correct"
}
{
"RATE_LIMIT": "Rate limit reached",
}
Example
{
"extendTo":1728704969000,
"maxPriceAccepted":165,
"receiver":"TFwUFWr3QV376677Z8VWXxGUAMF11111111",
"resourceType": "ENERGY"
}
{
"apikey": <YOUR_API_KEY>
}
{
"extend_order_book": [
{
"price": 108,
"value": 100000
},
{
"price": 122,
"value": 200000
}
],
"total_delegate_amount": 500000,
"total_available_extend_amount": 300000,
"total_estimate_trx": 24426224,
"is_able_to_extend": true,
"your_balance": 37780396,
"extend_data": [
{
"delegator": "TQBV7xU489Rq8ZCsYi72zBhJM44444444",
"is_extend": true,
"extra_amount": 0,
"extend_to": 1728704969000
},
{
"delegator": "TMN2uTdy6rQYaTm4A5g732kHR333333333",
"is_extend": true,
"extra_amount": 0,
"extend_to": 1728704969000
}
]
}
Example Code
const GetEstimateExtendData = async (extendTo, maxPriceAccepted) => {
const url = TRONSAVE_API_URL + `/v2/get-extendable-delegates`
const body = {
extendTo, //time in seconds you want to extend to
receiver: RECEIVER, //the address that receives the resource delegate
maxPriceAccepted, //Optional. Number the maximum price you want to pay to extend
resourceType: RESOURCE_TYPE, //ENERGY or BANDWIDTH. optional. The default is ENERGY
}
const data = await fetch(url, {
method: "POST",
headers: {
'apikey': API_KEY,
"content-type": "application/json",
},
body: JSON.stringify(body)
})
const response = await data.json()
/**
* Example response
* @link
{
"error": false,
"message": "Success",
"data": {
"extendOrderBook": [
{
"price": 784,
"value": 1002
}
],
"totalDelegateAmount": 5003,
"totalAvailableExtendAmount": 5003,
"totalEstimateTrx": 4085783,
"isAbleToExtend": true,
"yourBalance": 2377366851,
"extendData": [
{
"delegator": "TGGVrYaT8Xoos...6dmSZkohGGcouYL4",
"isExtend": true,
"extraAmount": 0,
"extendTo": 1745833276
},
{
"delegator": "TQBV7xU489Rq8Z...zBhJMdrDr51wA2",
"isExtend": true,
"extraAmount": 0,
"extendTo": 1745833276
},
{
"delegator": "TSHZv6xsYHMRCbdVh...qNozxaPPjDR6",
"isExtend": true,
"extraAmount": 0,
"extendTo": 1745833276
}
]
}
}
*/
return response
}
function getEstimateExtendData(int $extendTo, int $maxPriceAccepted): array {
$url = TRONSAVE_API_URL . "/v2/get-extendable-delegates";
$body = [
'extendTo' => $extendTo,
'receiver' => RECEIVER,
'maxPriceAccepted' => $maxPriceAccepted,
'resourceType' => RESOURCE_TYPE,
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'apikey: ' . API_KEY,
'Content-Type: application/json'
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}
def get_estimate_extend_data(extend_to: int, max_price_accepted: int) -> Dict[str, Any]:
"""Get estimate extend data"""
url = f"{TRONSAVE_API_URL}/v2/get-extendable-delegates"
headers = {
'apikey': API_KEY,
'Content-Type': 'application/json'
}
body = {
'extendTo': extend_to,
'receiver': RECEIVER,
'maxPriceAccepted': max_price_accepted,
'resourceType': RESOURCE_TYPE,
}
response = requests.post(url, headers=headers, json=body)
return response.json()
Last updated