# Get Order Book

To use this feature, you must have the API key. Read [here](/developer/get-api-key.md) to view how to get our API key

## Get the order book by API key

<mark style="color:blue;">`GET`</mark> `https://api.tronsave.io/v2/order-book`

Rate limi&#x74;***: 15** requests per **1** second*

#### Query Parameters

<table><thead><tr><th width="220">Name</th><th width="108">Type</th><th>Description</th></tr></thead><tbody><tr><td>address</td><td>String</td><td>energy reciver address</td></tr><tr><td>minDelegateAmount</td><td>Number</td><td>The minimum amount of energy delegated from one provider.</td></tr><tr><td>durationSec</td><td>Number</td><td>order duration in seconds</td></tr><tr><td>resourceType</td><td>String</td><td>"ENERGY" or "BANDWIDTH", default: ENERGY</td></tr></tbody></table>

{% tabs %}
{% tab title="200: OK " %}

<pre class="language-json"><code class="lang-json">{
    "error": false,
    "message": "Success",
    "data": [
        {
            price: number, // price in SUN
            availableResourceAmount: number, // available resource amount at this price
        },
        {}
    ]
}
<strong>
</strong></code></pre>

{% endtab %}
{% endtabs %}

*Example*&#x20;

**Query Params**

<table><thead><tr><th width="263">Key</th><th>Value</th></tr></thead><tbody><tr><td>address</td><td>TFwUFWr3QV376677Z8VWXxGUAMFSrq11111</td></tr><tr><td>resourceType</td><td>BANDWIDTH</td></tr><tr><td>minDelegateAmount</td><td>1000</td></tr><tr><td>durationSec</td><td>86400</td></tr></tbody></table>

{% tabs %}
{% tab title="Header" %}

```json
{
  "apikey": <YOUR_API_KEY>
}
```

{% endtab %}

{% tab title="Success Response" %}

```json
{
    "error": false,
    "message": "Success",
    "data": [
        {
            "price": 602,
            "availableResourceAmount": 1179
        },
        {
            "price": 650,
            "availableResourceAmount": 2409
        },
        {
            "price": 700,
            "availableResourceAmount": 5395
        },
        {
            "price": 701,
            "availableResourceAmount": 6613
        }
    ]
}
```

{% endtab %}
{% endtabs %}

*Example Code*

{% tabs %}
{% tab title="Javascript" %}

```javascript
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
}
```

{% endtab %}

{% tab title="PHP" %}

```php
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);
}
```

{% endtab %}

{% tab title="Python" %}

```python
/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()
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tronsave.io/developer/buy-resources-v2/use-api-key/get-order-book.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
