核心 API
获取价格
获取当前能量和带宽价格
GET
/
api
/
v1
/
prices
获取价格
curl --request GET \
--url https://api.example.com/api/v1/pricesimport requests
url = "https://api.example.com/api/v1/prices"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/api/v1/prices', 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/prices",
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/prices"
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/prices")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/prices")
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{
"energy_trx": {},
"energy_sun": {},
"energy_usd": {},
"energy_volume": 123,
"bandwidth_trx": {},
"bandwidth_sun": {},
"bandwidth_usd": {},
"bandwidth_volume": 123,
"trx_usd_rate": "<string>",
"burn_cost_trx": "<string>",
"burn_cost_usd": "<string>",
"savings_percent": "<string>"
}获取价格
返回当前能量和带宽的市场价格。 此端点为公开接口 — 无需身份验证。响应
65,000 单位能量的 TRX 价格,按时长键名(
1h)每 1 单位能量的 SUN 价格,按时长键名(
1h)65,000 单位能量的 USD 价格,按时长键名(
1h)用于能量价格计算的数量(65,000)
350 单位带宽的 TRX 价格,按时长键名(
1h)每 1 单位带宽的 SUN 价格,按时长键名(
1h)350 单位带宽的 USD 价格,按时长键名(
1h)用于带宽价格计算的数量(350)
当前 TRX/USD 汇率
燃烧 65,000 能量所需的 TRX 成本(不租赁的情况下)
相同的燃烧成本,以 USD 计
租赁与燃烧相比的节省百分比
示例
curl https://api.tronrental.com/v1/prices
import requests
resp = requests.get("https://api.tronrental.com/v1/prices")
print(resp.json())
const resp = await fetch("https://api.tronrental.com/v1/prices");
const data = await resp.json();
console.log(data);
以下响应值为示例。实际价格根据市场条件实时更新。
Response
{
"energy_trx": {"1h": "2.32"},
"energy_sun": {"1h": "35.68"},
"energy_usd": {"1h": "0.69"},
"energy_volume": 65000,
"bandwidth_trx": {"1h": "0.14"},
"bandwidth_sun": {"1h": "400.00"},
"bandwidth_usd": {"1h": "0.04"},
"bandwidth_volume": 350,
"trx_usd_rate": "0.297",
"burn_cost_trx": "6.5",
"burn_cost_usd": "1.93",
"savings_percent": "64.3",
"note": "Energy price is for 65,000 units in TRX"
}
⌘I
获取价格
curl --request GET \
--url https://api.example.com/api/v1/pricesimport requests
url = "https://api.example.com/api/v1/prices"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/api/v1/prices', 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/prices",
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/prices"
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/prices")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/prices")
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{
"energy_trx": {},
"energy_sun": {},
"energy_usd": {},
"energy_volume": 123,
"bandwidth_trx": {},
"bandwidth_sun": {},
"bandwidth_usd": {},
"bandwidth_volume": 123,
"trx_usd_rate": "<string>",
"burn_cost_trx": "<string>",
"burn_cost_usd": "<string>",
"savings_percent": "<string>"
}