接口說明
會查詢 目標地址 (destination) 是否為空地址,自動向 購買地址 (receiver) 發送65k 或者 131k 能量。
接口地址
GET https://web.apitrx.com/estimate
請求參數
| 參數名稱 | 類型 | 說明 | 示例 |
|---|---|---|---|
| apikey | string | TG機器人獲取的apikey | 83928AFB-14A5-4878-A63D-128467830293 |
| receiver | string | 接收能量的波場地址 | TX8BF429hr7qK1Te8UWLxD9xbumtX11111 |
| destination | string | 轉帳的目標地址(會查詢向這個地址轉帳所需能量) | TX8BF429hr7qK1Te8UWLxD9xbumtX22222 |
| traceId | string | (可選)鏈路追蹤ID,最長36位 | 7c2c1d6f-9b8a-4a6f-8c3d-2f5f9c1a4e7b |
返回參數
{
"code": 200,
"data": {
"amount": 2.0,
"balance": 99.5,
"receiver": "TX8BF429hr7qK1Te8UWLxD9xbumtX11111",
"destination": "TX8BF429hr7qK1Te8UWLxD9xbumtX22222",
"quantity": 131000,
"txid":"cedf46ed366fb89cddc1e892383c6f5abe2f16dbefa97b15c76989c111027880",
"traceId": "7c2c1d6f-9b8a-4a6f-8c3d-2f5f9c1a4e7b"
},
"message": "SUCCESS"
}
| 參數名稱 | 類型 | 說明 | 示例 |
|---|---|---|---|
| code | int | 200為成功,其他均為失敗 | 200/成功 500/失敗 501/帳戶禁用 502/餘額不足 |
| message | string | 提示訊息 | SUCCESS/ERROR |
| data.amount | float | 本次消費金額(TRX) | 2.0 |
| data.balance | float | 剩餘金額(TRX) | 99.5 |
| data.quantity | int | 本次發送數量 | 131000 |
| data.txid | string | 代理哈希值 | TX8BF429hr7qK1Te8UWLxD9xbumtX11111 |
| data.receiver | string | 接收地址 | TX8BF429hr7qK1Te8UWLxD9xbumtX22222 |
| data.destination | string | 目標地址 | cedf46ed366fb89cddc... |
| data.traceId | string | 請求時傳進來的鏈路追蹤 ID | 7c2c1d6f-9b8a-4a6f-8c3d... |
代碼示例
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
public class HttpGetWithParameters {
public static void main(String[] args) {
try {
// 设置要访问的URL
String baseUrl = "https://web.apitrx.com/estimate";
// 设置参数
String apiKey = "83928AFB-14A5-4878-A63D-128467830293";
String receiver = "TX8BF429hr7qK1Te8UWLxD9xbumtX11111";
String destination = "TX8BF429hr7qK1Te8UWLxD9xbumtX22222";
// 构建带参数的URL
String urlWithParams = baseUrl + "?" +
"apikey=" + URLEncoder.encode(apiKey, "UTF-8") +
"&receiver=" + URLEncoder.encode(receiver, "UTF-8") +
"&destination=" + URLEncoder.encode(destination, "UTF-8");
// 创建URL对象
URL obj = new URL(urlWithParams);
// 打开连接
HttpURLConnection connection = (HttpURLConnection) obj.openConnection();
// 设置请求方式为GET
connection.setRequestMethod("GET");
// 获取响应码
int responseCode = connection.getResponseCode();
System.out.println("Response Code: " + responseCode);
// 读取响应内容
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String inputLine;
StringBuilder response = new StringBuilder();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
// 关闭连接
in.close();
// 打印响应内容
System.out.println("Response Content: " + response.toString());
} catch (IOException e) {
e.printStackTrace();
}
}
}
package main
import (
"fmt"
"net/http"
"net/url"
)
func sendGetRequest() {
// 设置要访问的URL
baseURL := "https://web.apitrx.com/estimate"
// 设置参数
params := url.Values{}
params.Add("apikey", "83928AFB-14A5-4878-A63D-128467830293")
params.Add("receiver", "TX8BF429hr7qK1Te8UWLxD9xbumtX11111")
params.Add("destination", "TX8BF429hr7qK1Te8UWLxD9xbumtX22222")
// 构建带参数的URL
urlWithParams := baseURL + "?" + params.Encode()
// 发送GET请求
response, err := http.Get(urlWithParams)
if err != nil {
fmt.Println("Error:", err)
return
}
defer response.Body.Close()
// 读取响应内容
body, err := io.ReadAll(response.Body)
if err != nil {
fmt.Println("Error reading response:", err)
return
}
// 打印响应内容
fmt.Println("Response Code:", response.Status)
fmt.Println("Response Content:", string(body))
}
func main() {
sendGetRequest()
}
import requests
def send_get_request():
# 设置要访问的URL
url = "https://web.apitrx.com/estimate"
# 设置参数
params = {
'apikey': '83928AFB-14A5-4878-A63D-128467830293',
'receiver': 'TX8BF429hr7qK1Te8UWLxD9xbumtX11111',
'destination': 'TX8BF429hr7qK1Te8UWLxD9xbumtX22222'
}
# 发送GET请求
response = requests.get(url, params=params)
# 打印响应信息
print("Response Code:", response.status_code)
print("Response Content:", response.text)
if __name__ == "__main__":
send_get_request()
<?php
// 设置要访问的URL
$url = 'https://web.apitrx.com/estimate';
// 设置参数
$apiKey = '83928AFB-14A5-4878-A63D-128467830293';
$receiver = 'TX8BF429hr7qK1Te8UWLxD9xbumtX11111';
$destination = 'TX8BF429hr7qK1Te8UWLxD9xbumtX22222';
// 构建带参数的URL
$params = [
'apikey' => $apiKey,
'receiver' => $receiver,
'destination' => $destination
];
$urlWithParams = $url . '?' . http_build_query($params);
// 发送GET请求并获取响应内容
$response = file_get_contents($urlWithParams);
// 打印响应内容
echo $response;
?>
curl --location 'https://web.apitrx.com/estimate?apikey=83928AFB-14A5-4878-A63D-128467830293&receiver=TX8BF429hr7qK1Te8UWLxD9xbumtX11111&destination=TX8BF429hr7qK1Te8UWLxD9xbumtX22222'
