> For the complete documentation index, see [llms.txt](https://docs.tronsave.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tronsave.io/developers/api-reference/buy-resources/api-key.md).

# API Key

The API-key flow lets you buy resources (Energy and Bandwidth) from a prefunded TronSave internal account. Instead of signing a transaction with your wallet for every order, you authenticate each request with an API key and pay from your internal account balance — so there is no per-order on-chain fee and integration stays simple.

{% hint style="info" %}
Prefer to pay per order directly from your wallet? Use the [Buy with Signed Transaction](/developers/api-reference/buy-resources/signed-tx.md) flow instead.
{% endhint %}

## Before you start

You need a TronSave API key and an internal account with enough balance to cover your orders. There are two ways to create an API key:

* **Option 1:** Generate the API key on the TronSave website.
* **Option 2:** Generate the API key on Telegram.

See [Authentication](/developers/authentication.md) for how to pass the API key on each request.

## Endpoints

Use the API key to call any of the following endpoints:

| Endpoint                                                                                               | Description                                                                 |
| ------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------- |
| [Get Internal Account Info](/developers/api-reference/buy-resources/api-key/get-account-info.md)       | Read your internal account balance and details.                             |
| [Get Order Book](/developers/api-reference/buy-resources/api-key/get-order-book.md)                    | Fetch the current order book for resource pricing and availability.         |
| [Estimate TRX](/developers/api-reference/buy-resources/api-key/estimate-trx.md)                        | Calculate the TRX required for a resource amount and rental duration.       |
| [Buy Energy (Create Order)](/developers/api-reference/buy-resources/api-key/create-order.md)           | Place an order to buy Energy or Bandwidth, paid from your internal account. |
| [Get Order Details](/developers/api-reference/buy-resources/api-key/get-order-details.md)              | Look up the details and status of a single order by ID.                     |
| [Get Internal Account Order History](/developers/api-reference/buy-resources/api-key/order-history.md) | List the order history for your internal account.                           |

## Endpoints (TRON Nile Testnet)

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

* Estimate TRX: <mark style="color:orange;">`POST`</mark> `https://api-dev.tronsave.io/v2/estimate-buy-resource`
* Create order: <mark style="color:orange;">`POST`</mark> `https://api-dev.tronsave.io/v2/buy-resource`
* Get Internal Account Info: <mark style="color:blue;">`GET`</mark> `https://api-dev.tronsave.io/v2/user-info`
* Get Internal Account Order History: <mark style="color:blue;">`GET`</mark> `https://api-dev.tronsave.io/v2/orders`
* Get the order details: <mark style="color:blue;">`GET`</mark> `https://api-dev.tronsave.io/v2/order/:id`
* Get Order Book: <mark style="color:blue;">`GET`</mark> `https://api-dev.tronsave.io/v2/order-book`
  {% endtab %}
  {% endtabs %}

To integrate with the **Nile Testnet**, replace the base URL with <https://testnet.tronsave.io/> and follow the same steps.

## Next steps

* [Estimate TRX](/developers/api-reference/buy-resources/api-key/estimate-trx.md)
* [Buy Energy (Create Order)](/developers/api-reference/buy-resources/api-key/create-order.md)
* Learn the difference between [Energy and Bandwidth](/concepts/energy-and-bandwidth.md).
* Review the [Order Types](/concepts/order-types.md) before placing orders.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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/developers/api-reference/buy-resources/api-key.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.
