README
TronEnergize Public Rest API
TronEnergize Public Rest API Overview:
TronEnergize Public Rest API provides developers with a powerful toolset to interact programmatically with the TronEnergize energy marketplace. This API allows users to access essential market data, manage energy orders, and perform trading operations.
Key Features:
Market Data: Retrieve minimal prices and available energy to make informed decisions.
Order Management: View a list of active orders, create orders, and check the status of existing ones.
Trading Operations: Create unsigned RAW transactions for BUY orders, create and pay orders from internal wallets.
Authentication:
Secure your transactions with API Key and Secret for authentication.
HTTP Return Codes:
Easily interpret responses with clear HTTP return codes and error messages.
Ease of Use:
JSON responses make integration seamless, allowing developers to build customized interfaces and automate buying processes.
Explore the TronEnergize API to enhance your experience in the Tron energy market!
General API Information
The base endpoint is: https://tronenergize.com/
The nile TESTNET endpoint is: https://nile.tronenergize.com/
All endpoints return either a JSON object or array.
Data is returned in ascending order. Oldest first, newest last.
All time and timestamp related fields are in seconds.
HTTP Return Codes
HTTP
4XX
return codes are used for malformed requests; the issue is on the sender's side.HTTP
403
return code is used when the WAF Limit (Web Application Firewall) has been violated.HTTP
429
return code is used when breaking a request rate limit.HTTP
418
return code is used when an IP has been auto-banned for continuing to send requests after receiving429
codes.HTTP
5XX
return codes are used for internal errors; It is important to NOT treat this as a failure operation; the execution status isUNKNOWN and could have been a success.
Error Codes
Any endpoint can return an ERROR
Sample Payload below:
200
Success
400
Request body parameter format error
Usually appears on POST request, please check if the json structure is correct
403
Request frequency is limited
The access frequency per second is limited to 5qps. Please reduce the request frequency or add a new key
404
Missing required parameters
Please carefully check whether the parameter types and values of the document and the actual request are reasonable and valid
444
Data does not exist
500
Operation failed. Please try again later
502
Insufficient balance
505
Inactivated address
General Information on Endpoints
For
GET
endpoints, parameters must be sent as aquery string
.
Public API Endpoints
General endpoints
Test connectivity
Test connectivity to the Rest API.
Parameters: NONE
Response:
Minimum prices
Parameters: NONE
Response:
Available Energy
Parameters:
filter
'yes'
NO
Return of filtered available energy
Response:
Market Data endpoints
Order List.
This endpoint allows anyone to get a list of all active orders
Parameters: NONE
Response:
Trading endpoints
Create unsigned RAW transaction for BUY ENERGY Order.
Parameters:
buyer
STRING
YES
Resource purchase address
energyamount
integer
YES
Energy amount in SUN, minimum 32000
price
integer
YES
Minimum 45
duration
STRING
YES
5m, 1d, 3d, 7d, 14d, 30d, 1h and 6h are supported
Response:
Create unsigned RAW transaction for BUY BANDWIDTH Order.
Parameters:
buyer
STRING
YES
Resource purchase address
bandwidthamount
integer
YES
Bandwidth amount, minimum 2000
price
integer
YES
Minimum 600
duration
STRING
YES
5m, 1d, 3d, 7d, 14d, 30d, 1h and 6h are supported
Response:
Create BUY ENERGY Order.
Parameters:
buyer
STRING
YES
Resource purchase address
receiver
STRING
YES
Resource receiving address
energyamount
integer
YES
Energy amount in SUN, minimum 32000
price
integer
YES
Minimum 45
duration
STRING
YES
5m, 1d, 3d, 7d, 14d, 30d, 1h and 6h are supported
txid
STRING
YES
Signed and Broadcasted Transaction Hash
webhook
STRING
NO
Once the order has been filled, we will send event to your webhook url
Webhook Example : When the order has been filled, TronEnergize will send a GET HTTP request with order data. If your server is set up to listen for webhook deliveries at that URL, it can take action when it receives one.
webhook:
GET HTTP request:
Response:
Create BUY BANDWIDTH Order.
Parameters:
buyer
STRING
YES
Resource purchase address
receiver
STRING
YES
Resource receiving address
bandwidthamount
integer
YES
Bandwidth amount, minimum 2000
price
integer
YES
Minimum 600
duration
STRING
YES
5m, 1d, 3d, 7d, 14d, 30d, 1h and 6h are supported
txid
STRING
YES
Signed and Broadcasted Transaction Hash
webhook
STRING
NO
Once the order has been filled, we will send event to your webhook url
Webhook Example : When the order has been filled, TronEnergize will send a GET HTTP request with order data. If your server is set up to listen for webhook deliveries at that URL, it can take action when it receives one.
webhook:
GET HTTP request:
Response:
Status of order.
This endpoint returns the status ('active', 'filled', 'canceled') of order.
Parameters:
orderid
STRING
YES
Order Id.
Response:
Sell energy.
Parameters:
orderid
STRING
YES
Order Id
sender
STRING
YES
The address will receive payout
txid
STRING
YES
Signed and Broadcasted Transaction Hash
How to get order_id ?
Response:
Authentication
Authenticating to the TronEnergize API requires a valid API Key. Your API Key identifies your account (think of it as a username) and the API Secret authenticates your account (think of it as a password). Please follow the instructions below to secure your API Key and API Secret:
Do not send your API Secret with your API requests. Only send the API Key.
Do not share your API Secret or the API Key with anyone.
Do not commit your API Secret into source control systems like github.
If you lose your API Key or Secret, immediately contact Tronenergize support.
Please take note that if your API Secret is compromised, your funds are at risk.
Endpoint security type
Each next endpoint has a security type that determines how you will interact with it. This is stated next to the NAME of the endpoint.
If no security type is stated, assume the security type is NONE.
API-keys are passed into the Rest API via the
X-TR-APIKEY
header.API-keys and secret-keys are case sensitive.
SIGNED Endpoint security
SIGNED
endpoints require an additional parameter,signature
, to be sent in thequery string
orrequest body
orHEADERS
.The
signature
is not case sensitive.
Timing security
A
SIGNED
endpoint also requires a parameter,timestamp
, to be sent which should be the second timestamp of when the request was created and sent.
Request signing
Authenticated calls require you to send a request signature with every request. This signature should be re-generated for every request.
Example API Key/API Secret:
apiKey
API_my6mqen60xpwnewo2efckxtz
secretKey
S2808_61xkvn_bprxy5_s3szia
SIGNED Endpoint Examples for POST /api/v1/order
Here is a step-by-step example of how to send a valid signed payload from the
Linux command line using echo
, openssl
, and curl
.
receiver
TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t
energyamount
32000
price
35
duration
1d
timestamp
1695219834
Example 1: As a request body
requestBody: receiver=TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t&energyamount=32000&price=35&duration=1d×tamp=1695219834
HMAC SHA256 signature:
curl command:
Example 2: As a query string
queryString: receiver=TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t&energyamount=32000&price=35&duration=1d×tamp=1695219834
HMAC SHA256 signature:
curl command:
Create BUY ENERGY Order and pay from internal wallet.
HEADERS:
X-TR-APIKEY
STRING
YES
Your API Key
Parameters:
receiver
STRING
YES
Resource receiving address
energyamount
integer
YES
Energy amount in SUN, minimum 32000
price
integer
YES
Minimum 45
duration
STRING
YES
5m, 1d, 3d, 7d, 14d, 30d, 1h and 6h are supported
timestamp
integer
YES
Current timestamp in seconds
signature
STRING
YES
HMAC SHA256 signature
Response:
Create BUY BANDWIDTH Order and pay from internal wallet.
HEADERS:
X-TR-APIKEY
STRING
YES
Your API Key
Parameters:
receiver
STRING
YES
Resource receiving address
bandwidthamount
integer
YES
Bandwidth amount, minimum 2000
price
integer
YES
Minimum 600
duration
STRING
YES
5m, 1d, 3d, 7d, 14d, 30d, 1h and 6h are supported
timestamp
integer
YES
Current timestamp in seconds
signature
STRING
YES
HMAC SHA256 signature
Response:
Remove the Order.
HEADERS:
X-TR-APIKEY
STRING
YES
Your API Key
Parameters:
receiver
STRING
YES
Money receiving address
orderid
integer
YES
Order Id
timestamp
integer
YES
Current timestamp in seconds
signature
STRING
YES
HMAC SHA256 signature
Response:
Last updated