If your app, exchange, or bot sends USDT (TRC-20) at scale, you don’t want to buy energy by hand. The official TronSave SDK lets you estimate, buy, extend and track energy orders straight from your backend — in Node.js, Python, Rust, Java or PHP. This guide gets you from install to your first on-chain energy order.
The SDKs
All SDKs target the v2 API and wrap the same endpoints, so you get the same operations in every language:
| Language | Package | Install |
|---|---|---|
| TypeScript / JS | tronsave-sdk |
npm install tronsave-sdk |
| Python | tronsave |
pip install tronsave |
| Rust | tronsave |
cargo add tronsave |
| Java | io.tronsave:sdk |
Maven / Gradle |
| PHP | tronsave/sdk |
composer require tronsave/sdk |
Quickstart (Node.js)
The fastest route is the API-key flow: create an SDK instance, estimate the cost, then place the order. Grab an API key from the TronSave dashboard (see Authentication).
import { TronsaveSDK } from "tronsave-sdk";
const main = async () => {
const sdk = new TronsaveSDK({ network: "mainnet", apiKey: "your_api_key" });
const userInfo = await sdk.getUserInfo();
// Estimate cost for 65,000 ENERGY for 1 hour (one USDT transfer)
const estimate = await sdk.estimateBuyResource({
receiver: "TXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
resourceType: "ENERGY",
durationSec: 3600,
resourceAmount: 65000,
});
if (estimate.estimateTrx > Number(userInfo.balance)) throw new Error("Insufficient balance");
const { orderId } = await sdk.buyResource({
receiver: "TXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
resourceType: "ENERGY",
durationSec: 3600,
resourceAmount: 65000,
});
await new Promise((r) => setTimeout(r, 5000)); // wait ~5s to fill
const order = await sdk.getOrder(orderId);
console.log(order.fulfilledPercent < 100 ? "Not filled" : "Filled");
};
main();
Tip: use network: "testnet" (Nile) to develop with no real TRX, then switch to "mainnet" for production.
Python, Rust, Java & PHP
The other SDKs expose the same flow — install the package above, create a client with your API key, then call the equivalent estimate → buy → track methods. For exact per-language syntax, see the SDK reference. For example, in Python you start with pip install tronsave and follow the same estimate-then-buy pattern.
What the SDK can do
- Buy Resource — buy Energy or Bandwidth.
- Estimate Buy Resource — price a purchase before ordering.
- Extend Request — extend an existing delegation.
- Get User Info / Get Order(s) / Get Order Book — balances, order status and live market.
Prefer raw HTTP? The SDKs wrap the same endpoints in the API — see our API automation guide and, for high volume, buying energy in bulk.
FAQ
Do I need an API key?
The API-key flow is the simplest; you can also sign with a private key. Get a key from the dashboard.
Which languages are supported?
Node.js/TypeScript, Python, Rust, Java and PHP — all on the v2 API.
How much energy per USDT transfer?
About 65,000 (≈130,000 if the recipient has never held USDT).
Start building: read the TronSave docs and grab an API key on the market dashboard.
Python dev? See the language-specific walkthrough: how to buy TRON energy in Python (full runnable script).
