API TronRental cho người mới: mua năng lượng TRON trong 7 bước
A step-by-step guide for developers with no TRON experience. From registration to your first energy purchase via API.
Who Is This Guide For?
This guide is for developers, bot creators, and business owners who want to automate TRON energy and bandwidth purchases. No prior TRON experience required.
By the end of this guide you will be able to check prices, buy energy, buy bandwidth, and check order status — all from your own code.
What you can build with the API:
A bot that automatically buys energy before each USDT transfer
Integration into your own exchange, wallet, or payment service
Batch energy purchases for multiple addresses at once
What Is an API and Why Use It?
API (Application Programming Interface) is a way to control a service from your code instead of clicking buttons on a website. Think of it as a remote control for TronRental.
With TronRental API you can do everything the website does — check prices, buy energy, buy bandwidth — but automatically, from a script or server.
Manual vs API
Manual: open the site, log in, enter address, choose volume, click buy, wait, repeat
API: one HTTP request → energy is delegated in seconds. No browser needed.
Step 1 — Sign Up and Log In
Go to tronrental.com and create an account. You can sign up with email, Google, Telegram, or a TronLink wallet.
After registration, go to your Dashboard. This is where you manage everything: balance, orders, API keys, and settings.
Step 2 — Create an API Key
In the Dashboard, go to the API section and click "Create API Key".
Important: the API key is shown only once. Copy it and save it in a safe place. If you lose it, you will need to create a new one.
An API key is like a password for your script. It tells TronRental who is making the request and charges your account balance.
Optional: you can restrict the key to specific IP addresses for extra security. Only requests from those IPs will be accepted.
Optional: set a Webhook URL to receive automatic notifications when your order status changes (e.g., energy delegated).
Step 3 — Deposit Funds
Go to Dashboard → Deposit and copy your personal deposit address.
Send TRX or USDT (TRC-20) to this address. The deposit is usually confirmed within 30 seconds.
You can check your balance via API:
curl -X GET https://tronrental.com/api/v1/account/balance \
-H "Authorization: Bearer YOUR_API_KEY"# Python
import requests
API_KEY = "YOUR_API_KEY"
headers = {"Authorization": f"Bearer {API_KEY}"}
r = requests.get("https://tronrental.com/api/v1/account/balance", headers=headers)
print(r.json())// JavaScript (Node.js)
const API_KEY = "YOUR_API_KEY";
const res = await fetch("https://tronrental.com/api/v1/account/balance", {
headers: { "Authorization": `Bearer ${API_KEY}` }
});
console.log(await res.json());Response:
{
"balance_trx": "150.50",
"balance_usdt": "0.00",
"deposit_address": "TYour1Deposit2Address3Here..."
}Step 4 — Check Current Prices
Before buying, check the current prices. This endpoint is public — no API key required.
curl -X GET https://tronrental.com/api/v1/prices# Python
import requests
r = requests.get("https://tronrental.com/api/v1/prices")
print(r.json())// JavaScript
const res = await fetch("https://tronrental.com/api/v1/prices");
console.log(await res.json());Response:
{
"energy": {
"1h": "0.84",
"1d": "4.20"
},
"bandwidth": {
"1d": "9.60"
},
"burn_cost_trx": "6.43",
"savings_percent": "87"
}Response fields explained:
- energy.1h — price per 1,000 energy units for 1 hour (in TRX)
- bandwidth — price per 1,000 bandwidth for 1 day (in TRX)
- burn_cost_trx — how much TRX you would burn without energy
- savings_percent — how much you save by renting vs burning
Price formula: price_per_1k × (volume / 1000). For example, if energy.1h is 0.84 TRX and you need 65,000 energy: 0.84 × 65 = 54.6 TRX.
Step 5 — Buy Energy
Now the main part — buying energy. Send a POST request with the target address, volume, and duration.
Parameters:
target_address— target_address — the TRON address that will receive the energyvolume— volume — amount of energy (min 32,000, max 5,000,000)duration— duration — rental period: "1h" (1 hour) or "1d" (1 day)
How much energy do you need? For a USDT transfer: 65,000 if the recipient already has USDT, or 131,000 if they don't.
Request:
curl -X POST https://tronrental.com/api/v1/energy/buy \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"target_address": "TReceiverAddress...",
"volume": 65000,
"duration": "1h"
}'# Python
import requests
API_KEY = "YOUR_API_KEY"
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
data = {
"target_address": "TReceiverAddress...",
"volume": 65000,
"duration": "1h"
}
r = requests.post("https://tronrental.com/api/v1/energy/buy",
headers=headers, json=data)
print(r.json())// JavaScript (Node.js)
const API_KEY = "YOUR_API_KEY";
const res = await fetch("https://tronrental.com/api/v1/energy/buy", {
method: "POST",
headers: {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
target_address: "TReceiverAddress...",
volume: 65000,
duration: "1h"
})
});
console.log(await res.json());Response:
{
"id": 1234,
"type": "energy",
"target_address": "TReceiverAddress...",
"volume": 65000,
"duration": "1h",
"price_trx": "54.60",
"status": "pending",
"created_at": "2026-02-28T12:00:00Z"
}Order statuses:
- pending — order created, waiting to be processed
- delegated — energy has been delegated to the target address
- completed — rental period ended, energy reclaimed
Step 6 — Buy Bandwidth
Bandwidth works the same way as energy. It is required for any TRON transaction (not just USDT).
Parameters:
target_address— target_address — the TRON address that will receive bandwidthvolume— volume — amount of bandwidth (min 350, max 100,000)duration— duration — rental period: "1h"
Phí cố định 0.2 TRX được cộng thêm vào mỗi đơn hàng băng thông.
Request:
curl -X POST https://tronrental.com/api/v1/bandwidth/buy \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"target_address": "TReceiverAddress...",
"volume": 5000,
"duration": "1h"
}'# Python
import requests
API_KEY = "YOUR_API_KEY"
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
data = {
"target_address": "TReceiverAddress...",
"volume": 5000,
"duration": "1h"
}
r = requests.post("https://tronrental.com/api/v1/bandwidth/buy",
headers=headers, json=data)
print(r.json())// JavaScript (Node.js)
const API_KEY = "YOUR_API_KEY";
const res = await fetch("https://tronrental.com/api/v1/bandwidth/buy", {
method: "POST",
headers: {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
target_address: "TReceiverAddress...",
volume: 5000,
duration: "1h"
})
});
console.log(await res.json());Response:
{
"id": 1235,
"type": "bandwidth",
"target_address": "TReceiverAddress...",
"volume": 5000,
"duration": "1h",
"price_trx": "2.20",
"status": "pending",
"created_at": "2026-02-28T12:05:00Z"
}Step 7 — Check Order Status
After placing an order, you can check its status at any time.
Get all your orders:
curl -X GET https://tronrental.com/api/v1/orders \
-H "Authorization: Bearer YOUR_API_KEY"Get a specific order by ID:
curl -X GET https://tronrental.com/api/v1/orders/1234 \
-H "Authorization: Bearer YOUR_API_KEY"# Python
import requests
API_KEY = "YOUR_API_KEY"
headers = {"Authorization": f"Bearer {API_KEY}"}
# All orders
orders = requests.get("https://tronrental.com/api/v1/orders",
headers=headers).json()
# Single order
order = requests.get("https://tronrental.com/api/v1/orders/1234",
headers=headers).json()
print(order["status"]) # "delegated"Response:
{
"id": 1234,
"type": "energy",
"target_address": "TReceiverAddress...",
"volume": 65000,
"duration": "1h",
"price_trx": "54.60",
"status": "delegated",
"delegate_txid": "abc123def456...",
"created_at": "2026-02-28T12:00:00Z",
"delegated_at": "2026-02-28T12:00:04Z"
}Look for the "status" field. When it says "delegated", the energy or bandwidth has been successfully delivered to the target address. The "delegate_txid" field contains the on-chain transaction hash.
Best Practices & Tips
Security
Never hardcode your API key in source code. Use environment variables instead:
Python:
import os
API_KEY = os.environ["TRONRENTAL_API_KEY"]JavaScript/Node.js:
const API_KEY = process.env.TRONRENTAL_API_KEY;IP Whitelist
For production, always set an IP whitelist on your API key. This way, even if the key leaks, it cannot be used from another server.
Rate Limits
The API allows 30 requests per 60 seconds per key. If you exceed this, you will receive a 429 Too Many Requests response. Add a small delay between requests if you're making them in a loop.
Common Errors
Here are the most common error codes and what to do:
401 Unauthorized — invalid or missing API key. Check the Authorization header.
400 Bad Request — invalid parameters (e.g., volume too low). Check the error message in the response.
402 Payment Required — insufficient balance. Deposit more TRX.
429 Too Many Requests — rate limit exceeded. Wait and retry.
Webhooks
Instead of polling for order status, set up a webhook URL in your API key settings. TronRental will send a POST request to your URL whenever the order status changes.
The webhook payload includes the full order object with the updated status.
Frequently Asked Questions
How much energy do I need for a USDT transfer?
65,000 energy if the recipient already holds USDT, or 131,000 if they don't. Use our Energy Calculator to check any address.
How fast is the energy delegated?
Usually within 3-5 seconds after the order is placed. The status changes from "pending" to "delegated" as soon as the on-chain transaction is confirmed.
What happens if my balance runs out?
The API will return a 402 error. Your existing orders remain active until their rental period expires. Simply deposit more TRX and continue.
Can I buy energy for someone else's address?
Yes. The target_address parameter can be any valid TRON address. You don't need to own it.
Which programming languages are supported?
Any language that can make HTTP requests. The API is a standard REST API. We show examples in Python, JavaScript, and curl, but you can use Go, PHP, Java, Rust, or anything else.