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 · Updated
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].
The integration follows a structured five-step lifecycle[1]: fetching an instant estimate, generating HMAC-SHA256 request signatures[2], securing a 120-second price quote, placing an idempotent order with a custom client_order_id, and confirming delegation via signed webhooks.
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]. This public endpoint requires no API key:
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]:
X-API-KEY: Your key identifier (ak_live_...orak_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]. A quote pins the total cost for 120 seconds:
{
"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]. 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.
{
"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.confirmedevent signed with HMAC-SHA256[2]. - Polling: As a fallback, poll
GET /v1/orders/cid:bot-order-94812every 1–2 seconds untilstatustransitions toactivefollowing on-chaindelegateResource[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
- Separate environments: Develop and rehearse bot workflows using our Nile testnet endpoint (
https://api-nile.tenergy.me/v1). Testnet keys carry theak_test_prefix and are strictly isolated from production accounts. - Idempotency keys on every order: Generate a distinct
client_order_idfor every unique user action. This prevents accidental double billing during network interruptions. - Verify partial deliveries: Inspect the
partialboolean on order records. If supply runs short, an order can complete partially; the rest is refunded automatically. - Broadcast after confirmation: Wait for the
order.confirmedwebhook oractivestatus before broadcasting the dependent USDT TRC-20 transaction on TRON mainnet.
For technical details, review our full Quickstart guide, Authentication reference, and API documentation.
FAQ
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.
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.
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.
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.