---
title: Automate Buy Tron Energy with API Guide
description: "Buy TRON energy with the TronSave REST API v2: get an API key, estimate and create orders with curl or fetch, handle errors. Prices as of November 2026."
url: https://blog.tronsave.io/automate-buy-tron-energy-with-api-guide/
canonical: https://blog.tronsave.io/automate-buy-tron-energy-with-api-guide/
lang: en-US
datePublished: 2025-05-13T09:19:57+00:00
dateModified: 2026-11-16T23:02:23+00:00
author: TronSave
publisher: TronSave (https://tronsave.io/)
categories:
  - Tron Guidelines
keywords: buy tron energy with api,tron energy api,tronsave api,tronsave api key,tron energy rental api,buy-resource api v2
translations:
  ru: https://blog.tronsave.io/ru/kupit-energiyu-tron-cherez-api/
  es: https://blog.tronsave.io/es/automatizar-compra-energia-tron-api/
  pt: https://blog.tronsave.io/pt/comprar-energia-tron-com-api/
  zh: https://blog.tronsave.io/zh/api-goumai-bochang-nengliang-tronsave/
  de: https://blog.tronsave.io/de/tron-energie-per-api-kaufen/
---

# Automate Buy Tron Energy with API Guide

![Developer guide to buy Tron energy with API to reduce TRC-20 fees](https://blog.tronsave.io/wp-content/uploads/2025/05/Article-5-1024x597.jpg "How to buy Tron energy with API")

Source: TronSave blog

**Short answer (as of November 2026):** to buy TRON energy with an API, get a TronSave API key (connect a wallet on [tronsave.io/market](https://tronsave.io/market) → Account Info → Login TronSave), deposit at least 10 TRX into your internal account, then send two HTTP calls: `POST https://api.tronsave.io/v2/estimate-buy-resource` to price the order and `POST https://api.tronsave.io/v2/buy-resource` with the header `apikey: YOUR_API_KEY` to buy it. Check the result with `GET /v2/order/{orderId}`. Energy for one USDT transfer (about 65,000 units for 15 minutes) cost about 4.2 TRX in November 2026, against about 6.43 TRX burned.

This guide covers the raw REST API: plain HTTP calls you can make from any language, a cron job or a no-code tool. If you would rather install a package, the [TronSave SDK guide](https://blog.tronsave.io/buy-tron-energy-with-code-tronsave-sdk/) wraps the same endpoints for Node.js, Python, Rust, Java and PHP.

## Key takeaways

-   The current TronSave API is **v2** (base URL `https://api.tronsave.io`; Nile testnet `https://api-dev.tronsave.io`). The old v0 endpoints such as `/v0/estimate-trx` are legacy, kept only for backward compatibility.
-   Two ways to pay: an **API key** with a prefunded internal account (no on-chain signing per order, best for bots), or a **signed transaction** paid from your own wallet for each order (non-custodial).
-   One USDT (TRC-20) transfer needs about 64,285 energy to an address that holds USDT and about 130,285 to an address that never held USDT. Without energy the network burns about 6.43 TRX or 13.03 TRX (100 sun per energy unit, as of November 2026).
-   Most endpoints allow 15 requests per second. Errors come back as `{"error": true, "message": "TSAS:107 INVALID_API_KEY"}`\-style codes you can handle in code.
-   Renting energy instead of burning TRX saves up to 80%, depending on amount and duration.
-   Need prices only, not orders? The [TronSave price index JSON](https://blog.tronsave.io/tron-energy-price-index-json/) gives live energy and bandwidth rates with no API key.

## What does a TRON energy API do?

A TRON energy API lets your code rent energy, the TRON resource that pays for smart-contract calls such as USDT transfers, without opening a website. Your backend sends a request with a receiver address, an amount and a duration; TronSave matches it with energy sellers and the energy is delegated to that address, usually within seconds.

Why bother: an address with no energy pays for every USDT transfer by burning TRX. As of November 2026 the network charges 100 sun per energy unit, so a transfer burns about 6.43 TRX (about 13.03 TRX to an address that has never held USDT). The TRX amount does not depend on the TRX price; only its dollar value does. An exchange, payment gateway, wallet or payroll script that sends hundreds of transfers a day pays far less by renting the energy first. Background: [TRON energy and bandwidth explained](https://blog.tronsave.io/tron-energy-and-bandwidth/).

### Should your code rent, stake or burn?

| Option | Cost for one USDT transfer (November 2026) | Best for |
| --- | --- | --- |
| Burn TRX (no energy) | ≈ 6.43 TRX (≈ 13.03 TRX to a new USDT address) | Rare, one-off transfers |
| Rent via API, 15 minutes | ≈ 4.2 TRX for 65,000 energy at ≈ 65 sun | Bursty or unpredictable sending |
| Rent via API, 30 days | ≈ 2.4 TRX per transfer (1,000,000 energy at ≈ 37 sun per day) | Steady daily volume |
| Stake your own TRX | No per-transfer cost, but ≈ 6,650 TRX locked per daily transfer | Large TRX holders |

Prices come from the TronSave market on 12 November 2026 and change with supply and demand; see the monthly [TRON energy price report](https://blog.tronsave.io/tron-energy-price-report/) for the current grid. Staking math: [TRON Stake 2.0 guide](https://blog.tronsave.io/tron-stake-2-0-4-47-apy-energy-bandwidth/).

## How do you buy TRON energy with the API, step by step?

These steps use the API key method from the official [TronSave developer quickstart](https://docs.tronsave.io/developers/quickstart). Every example works on the Nile testnet if you swap the base URL for `https://api-dev.tronsave.io` (keys and balances are separate per network; Shasta is not supported).

### Step 1: Get an API key and fund the internal account

1.  Open [tronsave.io/market](https://tronsave.io/market) and click **Connect** to connect your wallet (TronLink or another TRON wallet).
2.  Click your address → **Account Info** → **Login TronSave**, and sign the message.
3.  Copy the **API key** and the **deposit address** that appear. You can also get the key in the [TronSave Telegram bot](https://blog.tronsave.io/how-to-buy-energy-and-bandwidth-on-telegram-with-tronsave/) under User Info → API key.
4.  Click **Top up** and send TRX to the deposit address. The minimum deposit is 10 TRX; the first deposit costs about 1 extra TRX to activate the address, and after 2 free deposits a day each extra deposit costs 0.3 TRX (TronSave docs, November 2026).

Check that the balance arrived (it updates in about 3 seconds):

```
curl https://api.tronsave.io/v2/user-info -H "apikey: YOUR_API_KEY"

# {"error": false, "data": {"balance": "50000000", "depositAddress": "T...", ...}}
# balance is in sun: 50000000 sun = 50 TRX
```

### Step 2: Keep the API key secret

-   The key spends your deposited TRX. Keep it on the server only: an environment variable or a secrets manager, never in front-end code or a git repository.
-   Deposit only what your bot needs for a few days. The internal balance then works as a spending cap.
-   If the key leaks, click **Revoke** (website or Telegram) to issue a new one. The old key stops working at once, so update every service that uses it.

### Step 3: Estimate the price, then create the order

Ask for a quote first. The estimate call needs no API key:

```
curl -X POST https://api.tronsave.io/v2/estimate-buy-resource \
  -H "Content-Type: application/json" \
  -d '{
    "receiver": "TYourReceiverAddress",
    "resourceType": "ENERGY",
    "resourceAmount": 65000,
    "durationSec": 900,
    "unitPrice": "MEDIUM"
  }'

# {"error": false, "data": {"unitPrice": 64, "durationSec": 900,
#   "estimateTrx": 4230000, "availableResource": 65000}}
```

`estimateTrx` is in sun (4,230,000 sun = 4.23 TRX). If `availableResource` is lower than your amount, the market cannot fill the whole order right now. `unitPrice` accepts `"SLOW"` (cheapest, not urgent), `"MEDIUM"` (default) or `"FAST"` (fill now, higher price). `durationSec` is the rental time in seconds: 900 = 15 minutes, 259200 = 3 days.

Then buy, with the same body plus your key and order options:

```
curl -X POST https://api.tronsave.io/v2/buy-resource \
  -H "apikey: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "receiver": "TYourReceiverAddress",
    "resourceType": "ENERGY",
    "resourceAmount": 65000,
    "durationSec": 900,
    "unitPrice": "MEDIUM",
    "options": {
      "allowPartialFill": true,
      "preventDuplicateIncompleteOrders": true,
      "maxPriceAccepted": 100
    }
  }'

# {"error": false, "message": "Success", "data": {"orderId": "6818426a65fa8ea36d119999"}}
```

What the options do: `allowPartialFill` accepts part of the amount when supply is short; `preventDuplicateIncompleteOrders` stops a retry from creating a second order while the first is still open; `maxPriceAccepted` (sun) rejects the order if the price is above your limit. For an order that must fill completely or not at all, use `onlyCreateWhenFulfilled: true`. How these map to the order types on the website: [TronSave order types explained](https://blog.tronsave.io/tronsave-order-types-explained/).

### Step 4: Check the order and the delegated energy

```
curl https://api.tronsave.io/v2/order/6818426a65fa8ea36d119999 -H "apikey: YOUR_API_KEY"

# "fulfilledPercent": 100  -> fully delegated
# "fulfilledPercent": 1-99 -> partly filled (only with allowPartialFill)
# "fulfilledPercent": 0    -> waiting for a seller
# "delegates": [{"delegator": "T...", "amount": 65000, "txid": "..."}]
```

Each `txid` is an on-chain delegation you can open on TronScan. To confirm the receiver really has the energy before you send USDT, read its resources from a TRON node (TronGrid `wallet/getaccountresource`; see [how to get a TronGrid API key](https://blog.tronsave.io/tron-api-key-how-to-access-blockchain-data-fast/)).

## What does the whole flow look like in code?

A minimal Node.js 18+ script (built-in `fetch`, no packages) that estimates, buys with a price cap and waits for the fill:

```
const API = "https://api.tronsave.io";        // testnet: https://api-dev.tronsave.io
const KEY = process.env.TRONSAVE_API_KEY;
const RECEIVER = process.env.RECEIVER;

async function call(path, body) {
  const res = await fetch(API + path, {
    method: body ? "POST" : "GET",
    headers: { "apikey": KEY, "Content-Type": "application/json" },
    body: body ? JSON.stringify(body) : undefined,
  });
  const json = await res.json();
  if (json.error) throw new Error(json.message);  // e.g. "TSAS:107 INVALID_API_KEY"
  return json.data;
}

async function buyEnergy(amount = 65000, durationSec = 900) {
  const order = { receiver: RECEIVER, resourceType: "ENERGY",
                  resourceAmount: amount, durationSec, unitPrice: "MEDIUM" };
  const est = await call("/v2/estimate-buy-resource", order);
  console.log("Estimated cost:", est.estimateTrx / 1e6, "TRX");

  const { orderId } = await call("/v2/buy-resource", { ...order,
    options: { allowPartialFill: true, preventDuplicateIncompleteOrders: true,
               maxPriceAccepted: 100 } });

  for (let i = 0; i < 12; i++) {                 // poll up to ~1 minute
    await new Promise(r => setTimeout(r, 5000));
    const s = await call("/v2/order/" + orderId);
    if (s.fulfilledPercent === 100) return s;
  }
  throw new Error("Order " + orderId + " not filled yet");
}

buyEnergy().then(s => console.log("Delegated", s.resourceAmount, "energy"));
```

The same three calls work from Python (`requests`), PHP (cURL), Go or a no-code HTTP step. More full examples are in the [TronSave code examples](https://docs.tronsave.io/developers/code-examples).

![TronSave energy market interface showing the Buy Energy panel and live order book](https://blog.tronsave.io/wp-content/uploads/2025/09/Energy-rental-interface-on-Tronsave-copy.png)

The TronSave energy market — set a target address, amount and price to rent TRON energy, with the live order book on the right. Source: TronSave.

## API key or signed transaction: which should you use?

|  | API key (internal account) | Signed transaction |
| --- | --- | --- |
| Who pays | Your prefunded TronSave balance | Your own wallet, per order |
| On-chain fee per order | None | Yes (the TRX payment transaction) |
| Integration | One header, simplest | Estimate → sign (your code or `POST /v2/signed-tx`) → create order |
| Custody | TronSave holds the deposited TRX | Non-custodial |
| Best for | Bots, exchanges, high-volume backends | Wallet apps and flows that must not hold funds with a third party |

Both use the same `/v2/estimate-buy-resource` and `/v2/buy-resource` endpoints; the signed-transaction flow sends the signed TRX payment with the order instead of the `apikey` header. Details: [Buy Resources in the TronSave docs](https://docs.tronsave.io/developers/api-reference/buy-resources).

## What else can the TronSave API do?

-   **Extend orders:** find delegations that can be extended and add time before they expire, instead of buying again (the same idea as [Extend on the website](https://blog.tronsave.io/extend-feature-extend-top-up-energy-without-ever-worrying-about-reclaim/)).
-   **Bandwidth:** set `resourceType` to `"BANDWIDTH"` for TRX transfers and other bandwidth-only transactions.
-   **Activate addresses:** check whether addresses are activated and activate up to 100 per request, useful before paying out to new users.
-   **Sell energy:** list your own staked energy on the market (these endpoints allow 2–3 requests per second).
-   **AI agents:** the [TronSave MCP server](https://blog.tronsave.io/tronsave-mcp-server-ai-agent-tron-energy/) exposes the same actions to Claude, Cursor and other MCP clients.

Not a developer? [Auto-Buy](https://blog.tronsave.io/tronsave-auto-buy-never-run-out-of-tron-energy/) keeps an address topped up without code.

## How much does buying energy by API save?

Example for a service that sends 200 USDT transfers a day to addresses that already hold USDT (prices as of November 2026):

| Method | TRX per day | TRX per 30 days |
| --- | --- | --- |
| Burn TRX (≈ 6.43 TRX each) | ≈ 1,286 | ≈ 38,570 |
| Rent per transfer, 15 min (≈ 4.2 TRX each) | ≈ 840 | ≈ 25,200 |
| Rent a 30-day block (≈ 2.4 TRX per transfer) | ≈ 480 | ≈ 14,400 |

The 30-day block works because delegated energy refills over 24 hours, so a block of energy covers a steady number of transfers every day. Rental prices move with the market, so price each order with the estimate endpoint before you budget; savings reach up to 80% against burning TRX depending on amount and duration. Sizing help: [how much TRX you need to send USDT](https://blog.tronsave.io/how-much-trx-is-needed-to-send-usdt/).

## How do you keep an energy automation setup safe and reliable?

-   **Handle rate limits:** most endpoints allow 15 requests per second and return HTTP 429 `Rate limit reached` above that. Retry with backoff (1 s, 2 s, 4 s).
-   **Handle the common errors:** `API_KEY_REQUIRED` / `INVALID_API_KEY` (401, check the header), `INTERNAL_BALANCE_ACCOUNT_TOO_LOW` (top up), `CANNOT_FULFILLED` (allow partial fill or raise `unitPrice`), `PRICE_EXCEED_MAX_PRICE_REQUIRED` (market above your `maxPriceAccepted`). Match on the code, not the message text.
-   **Make retries safe:** keep `preventDuplicateIncompleteOrders: true` so a timeout plus retry does not buy twice.
-   **Cap the price:** set `maxPriceAccepted` below the 100 sun burn price (as of November 2026); renting above it never makes sense.
-   **Test on Nile first:** get test TRX from the Nile faucet and run the full flow on `api-dev.tronsave.io`.

## Frequently asked questions

### Does TronSave have an API for buying TRON energy?

Yes. The TronSave REST API v2 at `https://api.tronsave.io` lets you estimate, buy, check and extend energy and bandwidth orders. Official SDKs for Node.js, Python, Rust, Java and PHP and an MCP server use the same API.

### How do I get a TronSave API key?

Connect a wallet on tronsave.io/market, open Account Info, click Login TronSave and sign. The API key and deposit address appear there. In the Telegram bot it is under User Info → API key.

### Is the v0 API (/v0/estimate-trx) still working?

It is kept for backward compatibility, but TronSave documents v2 as the current API as of November 2026. New integrations should use `/v2/estimate-buy-resource` and `/v2/buy-resource`.

### How much energy should my code buy for one USDT transfer?

About 65,000 energy if the receiver already holds USDT and about 131,000 if it never held USDT (64,285 and 130,285 exactly, as of November 2026). Buying a little extra covers small contract changes.

### How fast does the energy arrive?

Usually within a few seconds to a few minutes after the order is matched. Poll `GET /v2/order/{orderId}` until `fulfilledPercent` is 100 before you send the transfer.

### Can I buy energy for another address?

Yes. Set `receiver` to any TRON address, for example a customer's or a hot wallet's. The payer and the receiver can be different. See [buying energy for another wallet](https://blog.tronsave.io/buy-tron-energy-for-another-wallet/).

### Why does my USDT transfer still burn TRX after buying energy?

The order may be only partly filled, the energy may have gone to a different address, the rental may have expired, or the receiver never held USDT and the transfer needs about 130,285 energy. The sender also needs bandwidth (or a little TRX) for the transaction itself.

**⚠️ Not financial advice.** This article is for educational and informational purposes only and reflects the author’s opinion at the time of writing. It is **not** investment, financial, legal, or tax advice. Cryptocurrency is highly volatile and you can lose your entire principal; prices, APYs, and on-chain fees change constantly and may be out of date. Always **do your own research (DYOR)** and consult a licensed financial advisor before buying, selling, staking, or lending any digital asset.

**Disclosure:** This is the official TronSave blog. TronSave sells TRON energy/resource (fee-reduction) services and has a commercial interest in the products and topics covered here.

**Prefer an SDK?** See [how to buy TRON energy with code](https://blog.tronsave.io/buy-tron-energy-with-code-tronsave-sdk/) using the TronSave SDK (Node.js, Python, Rust, Java, PHP).
