v2 — Extend with API Key

Full working example showing how to extend an existing TronSave order using an API Key, in JavaScript, PHP, and Python.

This is a complete, runnable example for extending an existing order on TronSave using an API Key. It calls the v2 extend endpoints in two steps: first it estimates which delegates are extendable and how much TRX it will cost, then it submits the extend request and returns an orderId.

Prerequisites

You need a TronSave API Key tied to an Internal Account. There are two ways to obtain one:

  • Option 1: Generate the API Key on the TronSave website.

  • Option 2: Generate the API Key on Telegram.

See Authentication for both methods and details on how the API Key authorizes requests against your Internal Account.

The JavaScript example below uses only the built-in fetch API and does not require TronWeb. The original source noted a TronWeb 5.3.2 requirement for related examples; install it only if your wider integration needs signing:

Read more in the TronWeb 5.3.2 release notes.

How it works

The flow uses two endpoints:

  1. /v2/get-extendable-delegates — returns the extendData payload, the estimated TRX cost, and whether the extension is possible.

  2. /v2/extend-request — submits the extendData and returns an orderId.

Set these variables before running:

Variable
Description

API_KEY

Your TronSave API Key.

RECEIVER

The address that receives the resource delegate.

RESOURCE_TYPE

ENERGY or BANDWIDTH. Optional; defaults to ENERGY.

extendTo

The time, in seconds (Unix timestamp), you want to extend the delegation to.

maxPriceAccepted

Optional. The maximum price (in SUN) you are willing to pay to extend.

Full example

Next steps

Last updated