Tronsave
🇬🇧 English
🇬🇧 English
  • 📗INTRODUCTION
    • What is Tronsave ?
    • Why Tronsave?
  • Buyer
    • How to buy Energy ?
      • Buy on the Website
      • Buy on Telegram
        • 1. Create a Tronsave telegram account
        • 2. How To Deposit TRX
        • 3. Get the Tronsave API Key
        • 4. How to buy on Telegram
    • Extend
      • Quick extend
      • Advance
  • 🏬Seller
    • Get Energy by Staking 2.0
    • Permission
    • Sell Energy
      • Manual Sell
      • Auto Sell
      • Sell Suggestion
  • DEVELOPER
    • Get API key
      • On the Website
      • On Telegram
    • Buy Resources (v2)
      • Use Signed Transaction
        • Estimate TRX
        • Get Signed Transaction
        • Create order
      • Use API Key
        • Get Internal Account Info
        • Get Order Book
        • Estimate TRX
        • Create order
        • Get one order details
        • Get Internal Account Order History
    • Extend Orders (v2)
      • Step 1: Get Extendable Delegates
      • Step 2: Extend Request
    • Rest API v0
      • Buy on Rest API
        • Use Signed Transaction
          • Estimate TRX
          • Get Signed Transaction
          • Create order
          • Demo
        • Use API Key
          • Get Internal Account Info
          • Get Order Book
          • Estimate of TRX
          • Create order
          • Get one order details
          • Get Internal Account Order History
      • Extend with Rest API
  • 🤝Referrer
    • Referrals
  • 💡FAQ
    • Questions for Energy market
    • Calculate APY in TronSave
    • How to connect wallet in Tronsave?
    • Team of Service
  • 👨‍💻Full Code Example
    • Code Example (v2)
      • Buy Resource by API using private key
      • Buy Resources by API using api key
      • Extend order by API using api key
      • Extend order by API using private key
    • Code Example (v0)
      • Buy energy by API using private key
      • Buy energy by API using api key
      • Extend order by API using api key
Powered by GitBook
On this page
  1. DEVELOPER
  2. Buy Resources (v2)
  3. Use API Key

Get Order Book

PreviousGet Internal Account InfoNextEstimate TRX

Last updated 2 days ago

To use this feature, you must have the API key. Read to view how to get our API key

Get the order book by API key

GET https://api.tronsave.io/v2/order-book

Rate limit: 15 requests per 1 second

Query Parameters

Name
Type
Description

address

String

energy reciver address

minDelegateAmount

Number

The minimum amount of energy delegated from one provider.

durationSec

Number

order duration in seconds

resourceType

String

"ENERGY" or "BANDWIDTH", default: ENERGY

{
    "error": false,
    "message": "Success",
    "data": [
        {
            price: number, // price in SUN
            availableResourceAmount: number, // available resource amount at this price
        },
        {}
    ]
}

Example

Query Params

Key
Value

address

TFwUFWr3QV376677Z8VWXxGUAMFSrq11111

resourceType

BANDWIDTH

minDelegateAmount

1000

durationSec

86400

{
  "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()
here