TRONAgg API
What is TRONAgg API?
The TRONAgg API lets you automate TRON energy purchases at the best price across multiple providers. Your application can programmatically get quotes, purchase energy, and track orders — all through a simple REST API.
Base URL
https://tronagg.ai/api/v1
All endpoints are relative to this base URL.
Authentication
Every request requires an API key in the X-API-Key header. Create one in the TRONAgg Dashboard under API Keys.
curl -H "X-API-Key: ta_your_key_here" https://tronagg.ai/api/v1/account
See the Authentication guide for key management, security best practices, and error handling.
Endpoints Overview
The API has four endpoints covering a typical purchase workflow:
| Endpoint | Method | Description |
|---|---|---|
/account | GET | Check your balance, deposit address, and wallet |
/estimate | GET | Get a price quote before buying |
/buy | POST | Purchase energy for a receiver address |
/order/{id} | GET | Track order status and get delegation TX IDs |
Ready to make your first call? Follow the Quickstart for a step-by-step walkthrough, or jump to Code Examples for copy-paste Python and JavaScript snippets.
Integrate with an AI coding assistant
Rather than write the client by hand, hand the whole integration to an AI coding assistant. Paste the prompt below into Claude, Cursor, or ChatGPT — it carries everything the assistant needs (base URL, X-API-Key auth, SUN units, and the endpoints) to build a working integration.
You are integrating the TRONAgg REST API to buy TRON Energy programmatically.
- Base URL: https://tronagg.ai/api/v1
- Auth: send my API key in an `X-API-Key` header on every request (keep it in an env var, never hardcode).
- Units: integer amounts are in SUN (1 TRX = 1,000,000 SUN); `*_trx` amounts are JSON strings — parse with a decimal type.
Core flow:
- GET /account — my balance and deposit address.
- GET /estimate?resource_amount=<energy> — a price quote, incl. min_amount/max_amount order limits.
- POST /buy — JSON body {"receiver_address": "T...", "resource_amount": <energy>}. Always send a unique Idempotency-Key header; on timeout retry with the SAME key — it returns the original order, never a double charge.
- GET /order/{id} — poll every 2-3s until status is "COMPLETED" or "FAILED" (statuses are UPPERCASE). FAILED orders are auto-refunded.
History & webhooks (optional):
- GET /orders, GET /transactions, GET /deposits — order history, balance ledger, deposit history (deposits: credited_at = spendable, verified_at = reorg-safe).
- POST /webhooks {"name", "url"} — push instead of polling; store the signing_secret from the response (shown once) and verify HMAC-SHA256 over "{timestamp}.{raw_body}" from the X-TronAgg-Signature header.
Errors arrive as {"detail": {"error": "<code>", ...}} — handle insufficient_balance and duplicate_request (409) gracefully.
Build a small typed client that estimates the cost, buys Energy for a receiver, then polls the order until it reaches a terminal status.
Prefer not to write code at all? The same operations are available as an MCP server — connect your assistant directly and let it call TRONAgg as a tool instead of writing an integration. See Use TRONAgg from AI agents (MCP).
Error Codes
| Code | Description |
|---|---|
400 | Bad request — check your parameters |
401 | Unauthorized — invalid or missing API key |
402 | Insufficient balance — top up your account |
404 | Resource not found |
422 | Validation error — see detail field for specifics |
429 | Rate limit exceeded — slow down requests |
500 | Server error — retry or contact support |
Rate Limits
The API is rate-limited to ensure fair usage. If you exceed the limit, you'll receive a 429 Too Many Requests response. Wait a few seconds before retrying.
Authentication
- API Key: ApiKeyAuth
API key obtained from your TRONAgg Dashboard under API Keys. Keys use the format ta_... and must be passed in the X-API-Key header with every request. Keep your key secret — regenerate it immediately if compromised.
Security Scheme Type: | apiKey |
|---|---|
Header parameter name: | X-API-Key |