# TRON Energy Rental API for Bots: Integration &amp; Workflow

Source: https://tenergy.me/learn/energy-api-for-bots

1.  [TEnergy](/)
2.  [Learn](/learn)
3.  TRON energy rental API for bots and backend services

# TRON energy rental API for bots and backend services

Integrate TRON energy rental into Telegram bots and payment backends. Learn the 5-step REST workflow: estimates, HMAC signing, quotes, orders, and webhooks.

Published October 2, 2026 · Updated October 3, 2026

Automating TRON energy rental enables Telegram bots, payment processors, and automated payout daemons to execute USDT TRC-20 transfers without manually managing TRX stakes or burning liquid gas. Rather than building custom staking infrastructure or freezing working capital in 14-day network locks, bot developers connect to a programmatic REST API that delegates on-chain energy on demand via Stake 2.0[\[3\]](#source-3).

The integration follows a structured five-step lifecycle[\[1\]](#source-1): fetching an instant estimate, generating HMAC-SHA256 request signatures[\[2\]](#source-2), securing a 120-second price quote, placing an idempotent order with a custom `client_order_id`, and confirming delegation via signed webhooks.

Before running automated orders in production, test your bot’s signing, ordering, and webhook logic against our Nile testnet environment (`https://api-nile.tenergy.me/v1`).

## The 5-step bot integration lifecycle

Our REST API provides a predictable workflow designed for automated backends:

```
[Bot / Server]                      [Energy API]                      [TRON Chain]
       |                                   |                                |
       |--- 1. GET /v1/estimate ---------->|                                |
       |<-- Returns total SUN & price -----|                                |
       |                                   |                                |
       |--- 2. POST /v1/quotes ----------->|                                |
       |<-- Returns quote_id (120s lock) --|                                |
       |                                   |                                |
       |--- 3. POST /v1/orders ----------->|                                |
       |<-- 201 Created (ord_...) ---------|--- delegateResource ---------->|
       |                                   |                                |
       |<-- 4. Webhook: order.confirmed ---|<-- Confirmed in block ---------|
       |                                   |                                |
       |--- 5. Broadcast USDT transfer ------------------------------------>|
```

### 1\. Estimate order cost without credentials

To display instant pricing to bot users or compute transfer fees, query `GET /v1/estimate`[\[1\]](#source-1). This public endpoint requires no API key:

bash

```bash
curl -sG https://api.tenergy.me/v1/estimate \
  -d resource=energy -d amount=65000 -d tier=1h \
  -d receiver=TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE
```

The response returns `total_amount_sun`, `price_sun_per_unit`, and detects whether the receiver wallet is activated on chain.

### 2\. Sign requests with HMAC-SHA256

All authenticated endpoints require three HTTP headers[\[2\]](#source-2):

-   `X-API-KEY`: Your key identifier (`ak_live_...` or `ak_test_...`).
-   `X-API-TIMESTAMP`: ISO 8601 UTC timestamp (5-second tolerance).
-   `X-API-SIGN`: `base64(HMAC-SHA256(secret, timestamp + METHOD + path + query + body))`.

### 3\. Pin price with a 120-second quote

To shield your bot against price fluctuations during user interaction, call `POST /v1/quotes`[\[1\]](#source-1). A quote pins the total cost for 120 seconds:

json

```json
{
  "resource": "energy",
  "amount": 65000,
  "tier": "1h",
  "receiver": "TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE"
}
```

### 4\. Submit an idempotent order

Pass the `quote_id` and your own `client_order_id` to `POST /v1/orders`[\[1\]](#source-1). If your server loses connection or times out, safely retry the identical call; our engine recognizes the client order ID and returns the existing order rather than creating a duplicate charge.

json

```json
{
  "quote_id": "qt_01J9Z5NB2K4R",
  "client_order_id": "bot-order-94812"
}
```

### 5\. Confirm on-chain delegation

Your bot should wait for confirmation before broadcasting the USDT transfer:

-   **Webhooks:** Register an HTTPS URL in your dashboard. When the delegation is verified on chain, the system delivers an `order.confirmed` event signed with HMAC-SHA256[\[2\]](#source-2).
-   **Polling:** As a fallback, poll `GET /v1/orders/cid:bot-order-94812` every 1–2 seconds until `status` transitions to `active` following on-chain `delegateResource`[\[3\]](#source-3).

## API endpoints summary

| Endpoint | Method | Auth Required | Purpose |
| --- | --- | --- | --- |
| `/v1/estimate` | `GET` | No | Public cost estimate for specified energy amount and receiver |
| `/v1/prices` | `GET` | No | Current day-part price grid and available rental tiers |
| `/v1/balance` | `GET` | Yes | Checks available account balance in SUN |
| `/v1/quotes` | `POST` | Yes | Locks pricing for 120 seconds (`quote_id`) |
| `/v1/orders` | `POST` | Yes | Creates an energy order with idempotency protection |
| `/v1/orders/cid:{id}` | `GET` | Yes | Queries order status by your bot’s internal reference |

## Key architecture practices for bot developers

1.  **Separate environments:** Develop and rehearse bot workflows using our Nile testnet endpoint (`https://api-nile.tenergy.me/v1`). Testnet keys carry the `ak_test_` prefix and are strictly isolated from production accounts.
2.  **Idempotency keys on every order:** Generate a distinct `client_order_id` for every unique user action. This prevents accidental double billing during network interruptions.
3.  **Verify partial deliveries:** Inspect the `partial` boolean on order records. If supply runs short, an order can complete partially; the rest is refunded automatically.
4.  **Broadcast after confirmation:** Wait for the `order.confirmed` webhook or `active` status before broadcasting the dependent USDT TRC-20 transaction on TRON mainnet.

For technical details, review our full [Quickstart guide](/docs/quickstart), [Authentication reference](/docs/authentication), and [API documentation](/api).

## Sources

1.  [TEnergy API specification: Quickstart and Order lifecycle](https://tenergy.me/docs/quickstart) [↩](#cite-ref-1 "Back to the text")
2.  [TEnergy API specification: HMAC-SHA256 Authentication](https://tenergy.me/docs/authentication) [↩](#cite-ref-2 "Back to the text")
3.  [TRON Stake 2.0 developer guide (delegateResource)](https://developers.tron.network/docs/stake-20) [↩](#cite-ref-3 "Back to the text")
4.  [Tether USD (USDT) contract TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t on Tronscan](https://tronscan.org/#/contract/TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t) [↩](#cite-ref-4 "Back to the text")

## FAQ

01

### How can a bot automate TRON energy rentals?

A bot backend calls the REST API in five steps: query a public estimate, sign the request with HMAC-SHA256, pin the price with a quote, submit an idempotent order, and listen for confirmed webhooks.

02

### Do bots need an API key to check live energy prices?

No. The GET /v1/estimate and GET /v1/prices endpoints are public and do not require authentication headers or API keys.

03

### How does the API prevent duplicate orders if a bot request times out?

Orders accept a unique client\_order\_id. If a network timeout occurs and the bot retries the identical request, the API returns the original order with status 200 without charging twice.

04

### Should a bot poll order status or use webhooks?

Webhooks with cryptographic signature verification are recommended for servers with public HTTPS endpoints. Polling GET /v1/orders/cid:{client\_order\_id} is supported as a fallback for local runtimes.

Didn't find your answer? Ask us on Telegram at [@tenergymebot](https://t.me/tenergymebot) or at [support@tenergy.me](mailto:support@tenergy.me) and we'll add it here.
