自动补充
带宽补充报价
在创建规则之前查看一次带宽补充的价格
GET
/
api
/
v1
/
bandwidth
/
auto-refill
/
quote
带宽补充报价
curl --request GET \
--url https://api.example.com/api/v1/bandwidth/auto-refill/quoteimport requests
url = "https://api.example.com/api/v1/bandwidth/auto-refill/quote"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/api/v1/bandwidth/auto-refill/quote', 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/bandwidth/auto-refill/quote",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/v1/bandwidth/auto-refill/quote"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/api/v1/bandwidth/auto-refill/quote")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/bandwidth/auto-refill/quote")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"add_volume": 123,
"duration": "<string>",
"estimated_cost_per_refill_trx": "<string>"
}带宽补充报价
返回您的账户按duration 补充一次 add_volume 带宽的费用:即采用这些设置的规则每次补充支付的价格,已包含固定手续费。不会创建任何东西,也不会扣费。需要 view 权限。
价格取决于调用方式。使用 API 密钥调用时,返回的是通过该 API 密钥创建的规则的价格;在网站上调用时,返回的是在网站上创建的规则的价格。这是请求时刻的价格,不包含激活链上尚不存在的地址的费用——激活费用会在首次补充时加上。
查询参数
number
必填
每次补充的带宽。范围 350 至 100,000,与创建规则时相同。
string
默认值:"1h"
每次补充的租赁时长:
1h 或 1d。响应
number
您查询的数量
string
您查询的时长——
1h 或 1dstring
您的账户补充一次的全部价格,已包含固定手续费
示例
curl "https://api.tronrental.com/v1/bandwidth/auto-refill/quote?add_volume=5000&duration=1d" \
-H "X-API-Key: your_api_key"
import requests
resp = requests.get(
"https://api.tronrental.com/v1/bandwidth/auto-refill/quote",
headers={"X-API-Key": "your_api_key"},
params={"add_volume": 5000, "duration": "1d"},
)
print(resp.json())
const resp = await fetch(
"https://api.tronrental.com/v1/bandwidth/auto-refill/quote?add_volume=5000&duration=1d",
{ headers: { "X-API-Key": "your_api_key" } },
);
console.log(await resp.json());
Response
{
"add_volume": 5000,
"duration": "1d",
"estimated_cost_per_refill_trx": "0.500000"
}
错误
| 状态 | 代码 | 触发条件 |
|---|---|---|
403 | FORBIDDEN | API 密钥缺少 view 权限 |
422 | — | 缺少 add_volume 或其超出 350 – 100,000 范围,或 duration 不是 1h 或 1d |
503 | TEMPORARILY_UNAVAILABLE | 暂时无法获取价格——请等待 Retry-After 给出的秒数后重试 |
{
"detail": {
"error": {
"code": "TEMPORARILY_UNAVAILABLE",
"message": "Please retry shortly"
}
}
}
detail 是数组:
{
"detail": [
{
"type": "literal_error",
"loc": ["query", "duration"],
"msg": "Input should be '1h' or '1d'",
"input": "2h",
"ctx": {"expected": "'1h' or '1d'"}
}
]
}
⌘I
带宽补充报价
curl --request GET \
--url https://api.example.com/api/v1/bandwidth/auto-refill/quoteimport requests
url = "https://api.example.com/api/v1/bandwidth/auto-refill/quote"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/api/v1/bandwidth/auto-refill/quote', 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/bandwidth/auto-refill/quote",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/api/v1/bandwidth/auto-refill/quote"
req, _ := http.NewRequest("GET", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.example.com/api/v1/bandwidth/auto-refill/quote")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/bandwidth/auto-refill/quote")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"add_volume": 123,
"duration": "<string>",
"estimated_cost_per_refill_trx": "<string>"
}