获取订单簿 (Order book)
要使用此功能,您必须拥有 API 密钥。请阅读这里以了解如何获取我们的 API 密钥。
通过 API 密钥获取订单簿
GET https://api.tronsave.io/v2/order-book
速率限制 (Rate limit): 每1秒15个请求。
Query Params
Name
Type
Description
address
String
能源接收地址
minDelegateAmount
number
从一个提供者委托的最低能源量。
durationSec
number
订单持续时间(秒)
resourceType
string
“ENERGY”或“BANDWIDTH”,默认: “ENERGY”
{
"error": false,
"message": "Success",
"data": [
{
"price": number, // 价格(单位:SUN)
"availableResourceAmount": number, // 此价格下可用的资源数量
},
{}
]
}
例子 (Example)
Query Params
Key
Val
address
TFwUFWr3QV376677Z8VWXxGUAMFSrq11111
minDelegateAmount
1000
durationSec
86400
resourceType
BANDWIDTH
{
"apikey": <YOUR_API_KEY>
}{
"error": false,
"message": "Success",
"data": [
{
"price": 602,
"availableResourceAmount": 1179
},
{
"price": 650,
"availableResourceAmount": 2409
},
{
"price": 700,
"availableResourceAmount": 5395
},
{
"price": 701,
"availableResourceAmount": 6613
}
]
}Example Code
const GetOrderBook = async (apiKey, receiverAddress) => {
const url = `${TRONSAVE_API_URL}/v2/order-book?address=${receiverAddress}`
const data = await fetch(url, {
headers: {
'apikey': apiKey
}
})
const response = await data.json()
/**
* Example response
{
error: false,
message: 'Success',
data: [
{ price: 54, availableResourceAmount: 2403704 },
{ price: 60, availableResourceAmount: 3438832 },
{ price: 61, availableResourceAmount: 4100301 },
{ price: 90, availableResourceAmount: 7082046 },
{ price: 91, availableResourceAmount: 7911978 }
]
}
*/
return response
}function getOrderBook(): array {
$url = TRONSAVE_API_URL . "/v2/order-book?address=" . RECEIVER_ADDRESS;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'apikey: ' . API_KEY
]);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response, true);
}/def get_order_book() -> Dict[str, Any]:
"""Get order book for resources"""
url = f"{TRONSAVE_API_URL}/v2/order-book"
headers = {'apikey': API_KEY}
params = {'address': RECEIVER_ADDRESS}
response = requests.get(url, headers=headers, params=params)
return response.json()Last updated