Create Order

Create an Energy or Bandwidth purchase order with an API key, paid from your TronSave internal account, and receive an orderId to track its status.

Create an Energy or Bandwidth purchase order using an API key. The order is paid from your prefunded internal account, so no per-order on-chain signing is required. On success the endpoint returns an orderId you can use to track the order status.

POST https://api.tronsave.io/v2/buy-resource

Rate limit: 15 requests per 1 second.

Headers

Name
Type
Description

apikey*

String

TronSave API key tied to your internal account. See Authentication to get your API key.

* Required.

Request body

Field
Type
Description

resourceType

String

"ENERGY" or "BANDWIDTH". Default: ENERGY.

unitPrice

Number, String

"FAST", "MEDIUM", "SLOW", or a number. Default: "MEDIUM".

- FAST: If the market is ready to fill = 100%, FAST = MEDIUM. If the market is ready to fill < 100%, FAST = MEDIUM + 10. If market ready to fill = 0%, FAST = SLOW + 20.

- MEDIUM: The lowest price for the maximum market fill for this order. If market is ready to fill = 0%, MEDIUM = SLOW + 10.

- SLOW: The lowest price that can be set for this order.

- If the price is a number, the price unit is SUN.

resourceAmount*

Number

The number of resources.

receiver*

String

Resource receiving address.

durationSec

Number

The duration of the bought resource, in seconds. Default: 259200 (3 days).

sponsor

String

Sponsor code.

options

Object

Optional.

options.allowPartialFill

Boolean

Allow the order to be filled partially or not.

options.onlyCreateWhenFulfilled

Boolean

true => order only creates when it can be fulfilled.

false => order will create even if it cannot be fulfilled.

Default value: false.

options.maxPriceAccepted

Number

Only create the order when the estimated price is less than this value.

options.preventDuplicateIncompleteOrders

Boolean

true => only create if no uncompleted order with the same parameters exists.

false => always create a new order, regardless of existing unfinished ones.

Default value: false.

options.minResourceDelegateRequiredAmount

Number

The minimum resource amount delegated by a single provider.

* Required.

Request body example

Responses

Returns the order ID on success.

Request examples

To integrate with the TRON Nile Testnet, replace the base URL with https://api-dev.tronsave.io.

Next steps

Last updated