# Step 1: Get Extendable Delegates

## Check all extendable delegates&#x20;

<mark style="color:orange;">`POST`</mark> `https://api.tronsave.io/v2/get-extendable-delegates`

Rate limi&#x74;***: 1** request per **1** second*

#### Headers

<table><thead><tr><th width="134">Name</th><th width="143">Type</th><th>Description</th></tr></thead><tbody><tr><td>apikey</td><td>String</td><td>Tronsave api key that present for internal account.</td></tr></tbody></table>

#### Request Body

<table><thead><tr><th width="166">Name</th><th width="167">Type</th><th>Description</th></tr></thead><tbody><tr><td>extendTo<mark style="color:red;">*</mark></td><td>String</td><td>Time in milliseconds you want to extend to</td></tr><tr><td>receiver<mark style="color:red;">*</mark></td><td>String</td><td>The address that received resource delegate</td></tr><tr><td>requester</td><td>String</td><td>The address of the requester.. If not provided, the requester is taken from the <strong>API key</strong>.</td></tr><tr><td>resourceType</td><td>String</td><td>"ENERGY" or "BANDWIDTH", default: "ENERGY"</td></tr><tr><td>maxPriceAccepted</td><td>Number</td><td>Number maximum price you want to pay to extend</td></tr></tbody></table>

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

```javascript
  {
            "extendOrderBook": [
                {
                    "price": 133,
                    "value": 64319
                },
                ...
            ], //Overview extends the resource amount at every single price
            "totalDelegateAmount": 64319, 
            //Total current delegate of receiver address in tronsave
            "totalAvailableExtendAmount": 64319,
            //Total available delegate of the receiver address in tronsave
            "totalEstimateTrx": 8554427,
            //Estimate TRX payout if using extend_data below to create extend request
            "yourBalance": 20000000,
            //api key's internal balance 
            "isAbleToExtend": true,
            //Compare balance internal and total_estimate_trx 
            "extendData": [
                {
                    "delegator": "TMN2uTdy6rQYaTm4A5g732kHRf72222222",
                    "isExtend": true,
                    "extraAmount": 0,
                    "extendTo": 1728459019
                }
            ]
            //extend_data that is used to create Extend requests in Step 2
}
```

{% endtab %}

{% tab title="400: Bad Request Invalid params" %}

```json
{
    "MISSING_PARAMS": "Missing some params in body",
    "INVALID_PARAMS": "Some params are invalid"
}
```

{% endtab %}

{% tab title="401: Unauthorized Invalid api key" %}

```json
{
    "API_KEY_REQUIRED": "Missing api key in headers",
    "INVALID_API_KEY": "api key not correct"
}
```

{% endtab %}

{% tab title="429: Too Many Requests Rate limit reached" %}

```json
{
    "RATE_LIMIT": "Rate limit reached",
}
```

{% endtab %}
{% endtabs %}

*Example*

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

```json
{
    "extendTo":1728704969000,
    "maxPriceAccepted":165,
    "receiver":"TFwUFWr3QV376677Z8VWXxGUAMF11111111",
    "resourceType": "ENERGY"
}
```

{% endtab %}

{% tab title="Headers" %}

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

{% endtab %}

{% tab title="Success Response" %}

```json
{
    "extendOrderBook": [
        {
            "price": 108,
            "value": 100000
        },
        {
            "price": 122,
            "value": 200000
        }
    ],
    "totalDelegateAmount": 500000,
    "totalAvailableExtendAmount": 300000,
    "totalEstimateTrx": 24426224,
    "isAbleToExtend": true,
    "yourBalance": 37780396,
    "extendData": [
        {
            "delegator": "TQBV7xU489Rq8ZCsYi72zBhJM44444444",
            "isExtend": true,
            "extraAmount": 0,
            "extendTo": 1728704969000
        },
        {
            "delegator": "TMN2uTdy6rQYaTm4A5g732kHR333333333",
            "isExtend": true,
            "extraAmount": 0,
            "extendTo": 1728704969000
        }
    ]
}
```

{% endtab %}
{% endtabs %}

*Example Code*

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

```javascript
const GetEstimateExtendData = async (extendTo, maxPriceAccepted) => {
    const url = TRONSAVE_API_URL + `/v2/get-extendable-delegates`
    const body = {
        extendTo, //time in seconds you want to extend to
        receiver: RECEIVER,   //the address that receives the resource delegate
        maxPriceAccepted, //Optional. Number the maximum price you want to pay to extend
        resourceType: RESOURCE_TYPE, //ENERGY or BANDWIDTH. optional. The default is ENERGY
    }
    const data = await fetch(url, {
        method: "POST",
        headers: {
            'apikey': API_KEY,
            "content-type": "application/json",
        },
        body: JSON.stringify(body)
    })
    const response = await data.json()
    /**
     * Example response 
     * @link  
       {
            "error": false,
            "message": "Success",
            "data": {
                "extendOrderBook": [
                    {
                        "price": 784,
                        "value": 1002
                    }
                ],
                "totalDelegateAmount": 5003,
                "totalAvailableExtendAmount": 5003,
                "totalEstimateTrx": 4085783,
                "isAbleToExtend": true,
                "yourBalance": 2377366851,
                "extendData": [
                    {
                        "delegator": "TGGVrYaT8Xoos...6dmSZkohGGcouYL4",
                        "isExtend": true,
                        "extraAmount": 0,
                        "extendTo": 1745833276
                    },
                    {
                        "delegator": "TQBV7xU489Rq8Z...zBhJMdrDr51wA2",
                        "isExtend": true,
                        "extraAmount": 0,
                        "extendTo": 1745833276
                    },
                    {
                        "delegator": "TSHZv6xsYHMRCbdVh...qNozxaPPjDR6",
                        "isExtend": true,
                        "extraAmount": 0,
                        "extendTo": 1745833276
                    }
                ]
            }
        }
     */
    return response
}
```

{% endtab %}

{% tab title="PHP" %}

```php
function getEstimateExtendData(int $extendTo, int $maxPriceAccepted): array {
    $url = TRONSAVE_API_URL . "/v2/get-extendable-delegates";
    $body = [
        'extendTo' => $extendTo,
        'receiver' => RECEIVER,
        'maxPriceAccepted' => $maxPriceAccepted,
        'resourceType' => RESOURCE_TYPE,
    ];

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($body));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, [
        'apikey: ' . API_KEY,
        'Content-Type: application/json'
    ]);
    $response = curl_exec($ch);
    curl_close($ch);
    return json_decode($response, true);
}
```

{% endtab %}

{% tab title="Python" %}

```python
def get_estimate_extend_data(extend_to: int, max_price_accepted: int) -> Dict[str, Any]:
    """Get estimate extend data"""
    url = f"{TRONSAVE_API_URL}/v2/get-extendable-delegates"
    headers = {
        'apikey': API_KEY,
        'Content-Type': 'application/json'
    }
    
    body = {
        'extendTo': extend_to,
        'receiver': RECEIVER,
        'maxPriceAccepted': max_price_accepted,
        'resourceType': RESOURCE_TYPE,
    }
    
    response = requests.post(url, headers=headers, json=body)
    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/extend-orders-v2/step-1-get-extendable-delegates.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.
