要使用此功能,您必须拥有 API 密钥。请阅读这里以了解如何获取我们的 API 密钥。
通过 API 密钥获取订单簿
GET
https://api.tronsave.io/v0/order-book
速率限制 (Rate limit): 每1秒15个请求。
Query Parameters
{
price: number, // 太阳(sun)中的价格
available_energy_amount: number, // 在此价格下的可用资源数量
}[]
例子 (Example)
[
{
"price": -1,
"available_energy_amount": 177451
},
{
"price": 30,
"available_energy_amount": 331088
},
{
"price": 35,
"available_energy_amount": 2841948
},
]
Example Code
const GetOrderBook = async (api_key, receiver_address) => {
const url = `https://api.tronsave.io/v0/order-book?address=${receiver_address}&min_delegate_amount=100000&duration_sec=86400`
const data = await fetch(url, {
headers: {
'apikey': api_key
}
})
const response = await data.json()
/**
* Example response
* @link https://docs.tronsave.io/buy-energy-on-telegram/using-api-key-to/get-order-book
[
{
"price": -1,
"available_energy_amount": 177451
},
{
"price": 30,
"available_energy_amount": 331088
},
{
"price": 35,
"available_energy_amount": 2841948
},
]
*/
return response
}
curl 'https://api.tronsave.io/v0/order-book?address={{receiver_address}}&min_delegate_amount=100000&duration_sec=86400' \
--header 'apikey: {{apikey}}'