账户
列出 API 密钥权限
API 密钥可拥有的权限,按类型分组
GET
/
api
/
v1
/
auth
/
api-keys
/
scopes
列出 API 密钥权限
curl --request GET \
--url https://api.example.com/api/v1/auth/api-keys/scopesimport requests
url = "https://api.example.com/api/v1/auth/api-keys/scopes"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/api/v1/auth/api-keys/scopes', 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/auth/api-keys/scopes",
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/auth/api-keys/scopes"
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/auth/api-keys/scopes")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/auth/api-keys/scopes")
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{
"read": [
"<string>"
],
"node": [
"<string>"
],
"write": [
"<string>"
],
"danger": [
"<string>"
],
"default": [
"<string>"
],
"locked": [
"<string>"
]
}列出 API 密钥权限
返回 API 密钥权限的目录,按控制台中的显示方式分组。可用它来查询有效的权限名称。 Node API 密钥是一种独立的密钥类型:它们只拥有node_api 权限,绝不会与其他权限同时存在,并且只能在 node.tronrental.com 使用。
您可以在控制台 → Node API 中以端点的形式创建它们;可拥有的数量取决于您的 Node API 套餐。
Node API 密钥不能调用此端点——REST API 会以 403 NODE_API_KEY_ONLY 拒绝它。参见 Node API → 端点与密钥。
响应
string[]
读取权限:
view、deposit_viewstring[]
Node API 权限:
node_api。拥有该权限的密钥不带任何其他权限string[]
会花费余额或更改服务的权限:
buy_energy、buy_bandwidth、smart_mode、transfer_packages、energy_resalestring[]
withdraw。在密钥上启用它需要 2FA 和非空的 IP 白名单string[]
未选择权限时,新 REST API 密钥获得的权限:所有读取和写入权限,不含
withdrawstring[]
每个 REST API 密钥始终拥有的权限:
view示例
curl https://api.tronrental.com/v1/auth/api-keys/scopes \
-H "X-API-Key: your_api_key"
Response
{
"read": ["view", "deposit_view"],
"node": ["node_api"],
"write": ["buy_energy", "buy_bandwidth", "smart_mode", "transfer_packages", "energy_resale"],
"danger": ["withdraw"],
"default": ["view", "deposit_view", "buy_energy", "buy_bandwidth", "smart_mode", "transfer_packages", "energy_resale"],
"locked": ["view"]
}
⌘I
列出 API 密钥权限
curl --request GET \
--url https://api.example.com/api/v1/auth/api-keys/scopesimport requests
url = "https://api.example.com/api/v1/auth/api-keys/scopes"
response = requests.get(url)
print(response.text)const options = {method: 'GET'};
fetch('https://api.example.com/api/v1/auth/api-keys/scopes', 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/auth/api-keys/scopes",
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/auth/api-keys/scopes"
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/auth/api-keys/scopes")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/api/v1/auth/api-keys/scopes")
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{
"read": [
"<string>"
],
"node": [
"<string>"
],
"write": [
"<string>"
],
"danger": [
"<string>"
],
"default": [
"<string>"
],
"locked": [
"<string>"
]
}