# 使用 API 密钥

有两种方法可以创建API密钥：

[选项1：在Tronsve网站上生成API密钥。](/chinese/developer/get-api-key/on-the-website.md)

[选项2：在Telegram上生成API密钥。](/chinese/developer/get-api-key/on-telegram.md)

您可以使用API密钥进行:

1. [获取内部账户信息](/chinese/developer/rest-api-v0/buy-on-rest-api/use-api-key/get-internal-account-info.md)
2. [获取订单簿](/chinese/developer/rest-api-v0/buy-on-rest-api/use-api-key/get-order-book.md)
3. [获取估算 TRX (Estimate TRX)](/chinese/developer/rest-api-v0/buy-on-rest-api/use-api-key/use-signed-transaction.md)
4. [购买能源](/chinese/developer/rest-api-v0/buy-on-rest-api/use-api-key/buy-energy.md)
5. [获取单个订单详情](/chinese/developer/rest-api-v0/buy-on-rest-api/use-api-key/get-one-order-details.md)
6. [获取内部账户订单历史](/chinese/developer/rest-api-v0/buy-on-rest-api/use-api-key/get-internal-account-order-history.md)

## **使用API密钥购买能源流程**

## **步骤 1：创建内部账户并存入资金**

* 创建一个内部账户。
* 将TRX存入内部账户。

[按照完整的指南获取API密钥](/chinese/developer/get-api-key.md)

### **步骤 2：检查账户信息**

* 使用[获取内部账户信息 API](/chinese/developer/rest-api-v0/buy-on-rest-api/use-api-key/get-internal-account-info.md)验证您的账户余额和状态。

### **步骤 3：检查可用能源**

* 调用[获取订单簿 API](/chinese/developer/rest-api-v0/buy-on-rest-api/use-api-key/get-order-book.md)查看系统中可用的能源数量。

### **步骤 4：估算所需的TRX**

* 在[获取估算 TRX API](/chinese/developer/rest-api-v0/buy-on-rest-api/use-api-key/use-signed-transaction.md)中输入所需的能源数量和租赁时长，以计算所需的TRX。

### **步骤 5：执行购买交易**

* 将计算出的TRX金额输入[创建订单 API](/chinese/developer/rest-api-v0/buy-on-rest-api/use-api-key/buy-energy.md)并发送请求。

### **步骤 6：检查订单详情和历史记录**

* 使用[获取单个订单详情 API](/chinese/developer/rest-api-v0/buy-on-rest-api/use-api-key/get-one-order-details.md)查看您的购买详情。
* 使用[获取内部账户订单历史 API](/chinese/developer/rest-api-v0/buy-on-rest-api/use-api-key/get-internal-account-order-history.md)检查您的交易历史记录。

### 测试用API列表 - Nile 测试网 <a href="#api-list-for-testing-tron-nile-testnet" id="api-list-for-testing-tron-nile-testnet"></a>

{% tabs %}
{% tab title="测试\_API" %}

* 获取估算 TRX: <mark style="color:orange;">`POST`</mark> `https://api-dev.tronsave.io/v0/estimate-trx`
* 购买能源: <mark style="color:orange;">`POST`</mark> `https://api-dev.tronsave.io/v0/internal-buy-energy`
* 获取内部账户信息: <mark style="color:blue;">`GET`</mark> `https://api-dev.tronsave.io/v0/user-info`
* 获取内部账户订单历史: <mark style="color:blue;">`GET`</mark> `https://api-dev.tronsave.io/v0/orders`
* 获取订单详情: <mark style="color:blue;">`GET`</mark> `https://api-dev.tronsave.io/v0/orders/:id`
* 获取订单簿: <mark style="color:blue;">`GET`</mark> `https://api-dev.tronsave.io/v0/order-book`
  {% 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/chinese/developer/rest-api-v0/buy-on-rest-api/use-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.
