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

# API 密钥

API 密钥流程让你可以从预充值的 TronSave 内部账户购买资源（能量和带宽）。你无需为每笔订单使用钱包签名交易，而是通过 API 密钥对每个请求进行身份验证，并从你的内部账户余额中付款——因此没有每笔订单的链上费用，集成也保持简单。

{% hint style="info" %}
更愿意直接从钱包按订单付款？请改用[使用签名交易购买](/chinese/developers/api-reference/buy-resources/signed-tx.md)流程。
{% endhint %}

## 开始之前

你需要一个 TronSave API 密钥，以及一个余额足以覆盖订单的内部账户。有两种方式创建 API 密钥：

* **方式 1：** 在 TronSave 网站上生成 API 密钥。
* **方式 2：** 在 Telegram 上生成 API 密钥。

有关如何在每个请求中传递 API 密钥的信息，请参阅[身份验证](/chinese/developers/authentication.md)。

## 端点

使用 API 密钥可调用以下任意端点：

<table><thead><tr><th width="264">端点</th><th>说明</th></tr></thead><tbody><tr><td><a href="/pages/oBCfxFYENeHoczFHgQix">获取内部账户信息</a></td><td>读取你的内部账户余额和详情。</td></tr><tr><td><a href="/pages/6dPTzDxd3JOAT08nU1QL">获取订单簿</a></td><td>获取当前订单簿，了解资源定价和可用情况。</td></tr><tr><td><a href="/pages/ekwcHd5m0CVhSTqs3nsP">预估 TRX</a></td><td>计算指定资源数量和租赁时长所需的 TRX。</td></tr><tr><td><a href="/pages/j0bfJXT4HM8kkzsyuZty">购买能量（创建订单）</a></td><td>下单购买能量或带宽，从内部账户付款。</td></tr><tr><td><a href="/pages/ts1wTU2ELul4YVcUVXAI">获取订单详情</a></td><td>通过 ID 查询单个订单的详情和状态。</td></tr><tr><td><a href="/pages/3boQTe7AmuISZgm69MgW">获取内部账户订单历史</a></td><td>列出你的内部账户的订单历史。</td></tr></tbody></table>

## 端点（TRON Nile 测试网）

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

* 预估 TRX：<mark style="color:orange;">`POST`</mark> `https://api-dev.tronsave.io/v2/estimate-buy-resource`
* 创建订单：<mark style="color:orange;">`POST`</mark> `https://api-dev.tronsave.io/v2/buy-resource`
* 获取内部账户信息：<mark style="color:blue;">`GET`</mark> `https://api-dev.tronsave.io/v2/user-info`
* 获取内部账户订单历史：<mark style="color:blue;">`GET`</mark> `https://api-dev.tronsave.io/v2/orders`
* 获取订单详情：<mark style="color:blue;">`GET`</mark> `https://api-dev.tronsave.io/v2/order/:id`
* 获取订单簿：<mark style="color:blue;">`GET`</mark> `https://api-dev.tronsave.io/v2/order-book`
  {% endtab %}
  {% endtabs %}

要与 **Nile 测试网**集成，请将基础 URL 替换为 <https://testnet.tronsave.io/>，并按照相同步骤操作。

## 后续步骤

* [预估 TRX](/chinese/developers/api-reference/buy-resources/api-key/estimate-trx.md)
* [购买能量（创建订单）](/chinese/developers/api-reference/buy-resources/api-key/create-order.md)
* 了解[能量和带宽](/chinese/concepts/energy-and-bandwidth.md)之间的区别。
* 下单前请查看[订单类型](/chinese/concepts/order-types.md)。


---

# 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/chinese/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.
