延长请求
要使用此功能,您必须拥有API密钥。请阅读这里以了解如何获取我们的API密钥。
步骤 1:检查所有可延长的委托
POST
https://api.tronsave.io/v0/get-extendable-delegates
通过API密钥检查可延长的委托
速率限制:每2秒1个请求
请求头
名称
类型
描述
apikey*
String
Tronsave API密钥,适用于内部账户
请求体
名称
类型
描述
extend_to*
String
你想要延长的时间(以毫秒为单位)
max_price
Number
你愿意支付的最大延长费用(数字)
receiver
String
接收资源委托的地址
{
"extend_order_book": [
{
"price": 133,
"value": 64319
},
...
], // 概述每个价格的扩展能源数量
"total_delegate_amount": 64319,
// 收件人在Tronsave上的当前总委托
"total_available_extend_amount": 64319,
// 收件人在Tronsave上的可用总委托
"total_estimate_trx": 8554427,
// 如果使用下面的extend_data创建延长请求,估算的TRX支付
"your_balance": 20000000,
// API密钥的内部余额
"is_able_to_extend": true,
// 比较余额和total_estimate_trx
"extend_data": [
{
"delegator": "TMN2uTdy6rQYaTm4A5g732kHRf72tKsA4w",
"is_extend": true,
"extra_amount": 0,
"extend_to": 1728459019000
}
]
// 用于创建下面延长请求的扩展数据
}
{
"API_KEY_REQUIRED": "Missing api key in headers",
"INVALID_API_KEY":"api key not correct"
}
{
"RATE_LIMIT": "Rate limit reached",
}
示例
{
"extend_to":1728704969000,
"max_price":165,
"receiver":"TFwUFWr3QV376677Z8VWXxGUAMF11111111"
}
{
"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": "TQBV7xU489Rq8ZCsYi72zBhJM2222222",
"is_extend": true,
"extra_amount": 0,
"extend_to": 1728704969000
},
{
"delegator": "TMN2uTdy6rQYaTm4A5g732kHR333333333",
"is_extend": true,
"extra_amount": 0,
"extend_to": 1728704969000
}
]
}
示例代码
const GetEstimateExtendData = async () => {
const url = `https://api.tronsave.io/v0/get-extendable-delegates`
const body = {
"extend_to": extend_to, // 你想要延长的时间(以毫秒为单位)
"receiver": RECEIVER, // 接收资源委托的地址
"max_price": max_price // 可选。你愿意支付的最大延长费用(数字)
}
const data = await fetch(url, {
method: "POST",
headers: {
'apikey': API_KEY,
"content-type": "application/json",
},
body: JSON.stringify(body)
})
const response = await data.json()
/**
* 示例响应:
{
"extend_order_book": [
{
"price": 133,
"value": 64319
}
],
"total_delegate_amount": 64319,
"total_available_extend_amount": 64319,
"total_estimate_trx": 8554427,
"is_able_to_extend": true,
"your_balance": 20000000,
"extend_data": [
{
"delegator": "TMN2uTdy6rQYaTm4A5g732kHRf72tKsA4w",
"is_extend": true,
"extra_amount": 0,
"extend_to": 1728459019000
}
]
}
*/
return response
}
步骤 2:通过API密钥创建延长请求
POST
https://api.tronsave.io/v0/internal-extend-request
通过API密钥创建新的延长请求订单
速率限制:每2秒1个请求
请求头
名称
类型
描述
apikey*
String
Tronsave API密钥,适用于内部账
请求体
名称
类型
描述
receiver*
String
接收资源的地址
extend_data*
Array
扩展数据数组。在API估算可延长委托的响应中获取。
如果成功,返回订单 ID 数组。
[<order_id_1>,<order_id_2>,...]
{
"API_KEY_REQUIRED": "Missing api key in headers",
"INVALID_API_KEY":"api key not correct"
}
{
"RATE_LIMIT": "Rate limit reached",
}
示例
{
"extend_data": [
{
"delegator": {{some_delegator_address}}, // 委托者地址
"is_extend": true,
"extra_amount": 0,
"extend_to": {{extend_timestamp_in_millisecs}} // 延长到的时间(以毫秒为单位)
},
...
],
"receiver": {{receiver_address}} // 接收者地址
}
{
"apikey": <YOUR_API_KEY>
}
["651d2306e55c073f6ca0992e","651d2306e55c073f6ca09923",...]
示例代码
const SendInternalExtendRequest = async () => {
const url = `https://api.tronsave.io/v0/internal-extend-request`
const body = {
"extend_data": [
{
"delegator": {{some_delegator_address}},
"is_extend": true,
"extra_amount": 0,
"extend_to": {{extend_timestamp_in_millisecs}}
}
],
"receiver": RECEIVER,
}
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 //TODO
[<order_id>]
*/
return response
}
return []
}
curl --location 'https://api.tronsave.io/v0/internal-extend-request' \
--header 'apikey: {{apikey}}' \
--data '
{
"extend_data": [
{
"delegator": {{some_delegator_address}}, // 委托者地址
"is_extend": true,
"extra_amount": 0,
"extend_to": {{extend_timestamp_in_millisecs}} // 延长到的时间(以毫秒为单位)
},
...
],
"receiver": {{receiver_address}} // 接收者地址
}
'
Last updated