自动补充
更新能量规则
修改、暂停或恢复能量自动补充规则
PATCH
/
api
/
v1
/
energy
/
auto-refill
/
{rule_id}
更新能量规则
curl --request PATCH \
--url https://api.example.com/api/v1/energy/auto-refill/{rule_id} \
--header 'Content-Type: application/json' \
--data '
{
"threshold_energy": 123,
"add_volume": 123,
"label": "<string>",
"status": "<string>"
}
'import requests
url = "https://api.example.com/api/v1/energy/auto-refill/{rule_id}"
payload = {
"threshold_energy": 123,
"add_volume": 123,
"label": "<string>",
"status": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({threshold_energy: 123, add_volume: 123, label: '<string>', status: '<string>'})
};
fetch('https://api.example.com/api/v1/energy/auto-refill/{rule_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/v1/energy/auto-refill/{rule_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'threshold_energy' => 123,
'add_volume' => 123,
'label' => '<string>',
'status' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/v1/energy/auto-refill/{rule_id}"
payload := strings.NewReader("{\n \"threshold_energy\": 123,\n \"add_volume\": 123,\n \"label\": \"<string>\",\n \"status\": \"<string>\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.example.com/api/v1/energy/auto-refill/{rule_id}")
.header("Content-Type", "application/json")
.body("{\n \"threshold_energy\": 123,\n \"add_volume\": 123,\n \"label\": \"<string>\",\n \"status\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/energy/auto-refill/{rule_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"threshold_energy\": 123,\n \"add_volume\": 123,\n \"label\": \"<string>\",\n \"status\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body更新能量规则
修改规则的阈值、数量或标签,或者暂停、恢复规则。只需发送要修改的字段;其他字段保持不变。更改从下一次检查起生效。需要buy_energy 权限。
规则的地址和时长无法修改。要把规则移到另一个地址,请删除它并创建一条新规则。
路径参数
number
必填
规则 ID——创建或列出能量规则时返回的
id请求体
number
新的阈值。范围 1 至 50,000,000。
number
每次补充的新能量数量。范围 32,000 至 5,000,000。
string
新的标签,最多 100 个字符。空字符串会移除标签。
string
"paused" 表示暂停规则,"active" 表示恢复规则。恢复时还会清除 stopped_reason,并将 consecutive_failures 重置为 0。因余额不足而停止的规则会在充值后自行恢复,因此您无需手动恢复;如果在余额仍然不足时恢复,它会在下一次检查时再次停止。stopped_insufficient_balance 不能直接设置。响应
更新后的规则,字段与列出能量规则中的相同。示例
curl -X PATCH https://api.tronrental.com/v1/energy/auto-refill/12 \
-H "X-API-Key: your_api_key" \
-H "Content-Type: application/json" \
-d '{"status": "paused"}'
import requests
resp = requests.patch(
"https://api.tronrental.com/v1/energy/auto-refill/12",
headers={"X-API-Key": "your_api_key"},
json={"status": "paused"},
)
print(resp.json())
const resp = await fetch("https://api.tronrental.com/v1/energy/auto-refill/12", {
method: "PATCH",
headers: { "X-API-Key": "your_api_key", "Content-Type": "application/json" },
body: JSON.stringify({ status: "paused" }),
});
console.log(await resp.json());
Response
{
"id": 12,
"target_address": "TYourRecipientAddress1234567890abc",
"label": "Hot wallet",
"threshold_energy": 65000,
"add_volume": 131000,
"duration": "1h",
"status": "paused",
"stopped_reason": null,
"consecutive_failures": 0,
"last_checked_at": "2026-10-14T09:41:02Z",
"last_available_energy": 212480,
"last_read_error_at": null,
"last_refill_at": "2026-10-14T08:57:40Z",
"refill_count": 3,
"total_spent_trx": "7.854000",
"created_at": "2026-10-14T08:12:05Z",
"estimated_cost_per_refill_trx": "2.618000",
"volume_below_threshold": false
}
错误
| 状态 | 代码 | 触发条件 |
|---|---|---|
403 | FORBIDDEN | API 密钥缺少 buy_energy 权限 |
404 | NOT_FOUND | 您的账户中没有此 ID 的能量规则(或已被删除) |
409 | AUTOREFILL_IN_PROGRESS | 该规则的一次补充正在购买中——请一分钟后重试 |
422 | — | 数值超出范围,或 status 不是 "active" 或 "paused" |
{
"detail": {
"error": {
"code": "AUTOREFILL_IN_PROGRESS",
"message": "A refill is in progress for this rule; try again in a minute"
}
}
}
⌘I
更新能量规则
curl --request PATCH \
--url https://api.example.com/api/v1/energy/auto-refill/{rule_id} \
--header 'Content-Type: application/json' \
--data '
{
"threshold_energy": 123,
"add_volume": 123,
"label": "<string>",
"status": "<string>"
}
'import requests
url = "https://api.example.com/api/v1/energy/auto-refill/{rule_id}"
payload = {
"threshold_energy": 123,
"add_volume": 123,
"label": "<string>",
"status": "<string>"
}
headers = {"Content-Type": "application/json"}
response = requests.patch(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PATCH',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({threshold_energy: 123, add_volume: 123, label: '<string>', status: '<string>'})
};
fetch('https://api.example.com/api/v1/energy/auto-refill/{rule_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/api/v1/energy/auto-refill/{rule_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PATCH",
CURLOPT_POSTFIELDS => json_encode([
'threshold_energy' => 123,
'add_volume' => 123,
'label' => '<string>',
'status' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/v1/energy/auto-refill/{rule_id}"
payload := strings.NewReader("{\n \"threshold_energy\": 123,\n \"add_volume\": 123,\n \"label\": \"<string>\",\n \"status\": \"<string>\"\n}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.patch("https://api.example.com/api/v1/energy/auto-refill/{rule_id}")
.header("Content-Type", "application/json")
.body("{\n \"threshold_energy\": 123,\n \"add_volume\": 123,\n \"label\": \"<string>\",\n \"status\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/energy/auto-refill/{rule_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"threshold_energy\": 123,\n \"add_volume\": 123,\n \"label\": \"<string>\",\n \"status\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body