# 1-Hour Energy Order Endpoint
The /order1h
endpoint allows you to rent TRON energy for a 1-hour period. This is useful for short-term needs like executing smart contracts or performing other energy-intensive operations on the TRON network.
# Endpoint URL
POST https://netts.io/apiv2/order1h
# Authentication
This endpoint requires authentication via an API key. See the Authentication page for details.
# Request Headers
Header | Required | Description |
---|---|---|
X-API-KEY | Yes | Your NETTS API key |
X-Real-IP | Yes | IP address that is whitelisted for your API key |
Content-Type | Yes | application/json |
X-ORDER-ID | No | Custom order ID (optional) |
X-COST | No | Custom cost override (optional, only for specific use cases) |
# IP Whitelist
All API requests must come from IP addresses that have been added to your whitelist. You can add up to 3 IP addresses to your whitelist on the dashboard page (opens new window).
# How to Add an IP to Your Whitelist
- Log in to your NETTS dashboard
- Navigate to the API tab: https://www.netts.io/workspace/dashboard.php?tab=api
- In the "IP Whitelist" section, click the "Add IP Address" button
- Enter a valid IPv4 or IPv6 address
- Confirm the addition
Note: Requests from IP addresses that are not included in your whitelist will be rejected with an authentication error.
# Request Body
Parameter | Type | Required | Description |
---|---|---|---|
amount | integer | Yes | Amount of energy to rent (32,000 to 131,000) |
receiveAddress | string | Yes | TRON address to receive the energy delegation |
# Example Requests
# CURL Example
curl -X POST "https://netts.io/apiv2/order1h" \
-H "Content-Type: application/json" \
-H "X-API-KEY: your_api_key" \
-H "X-Real-IP: your_whitelisted_ip" \
-d '{
"amount": 64000,
"receiveAddress": "TXyz123AbCdEfGhIjKlMnOpQrStUvWxYz"
}'
# Python Example
import requests
import json
# Request configuration
url = "https://netts.io/apiv2/order1h"
api_key = "your_api_key" # Your API key
# Request payload
payload = {
"amount": 64000, # Amount of energy (32,000 to 131,000)
"receiveAddress": "TXyz123AbCdEfGhIjKlMnOpQrStUvWxYz" # TRON address for delegation
}
headers = {
"Content-Type": "application/json",
"X-API-KEY": api_key,
"X-Real-IP": "your_whitelisted_ip" # IP from your whitelist
}
try:
# Send POST request to the order1h API
response = requests.post(url, json=payload, headers=headers, timeout=15)
# Process JSON response
if response.status_code == 200:
data = response.json()
print(json.dumps(data, ensure_ascii=False, indent=2))
# Extract key information
detail = data.get("detail", {})
result_code = detail.get("code")
message = detail.get("msg")
if result_code == 10000:
order_data = detail.get("data", {})
print(f"\nSuccess! Order Details:")
print(f"Order ID: {order_data.get('orderId')}")
print(f"Provider: {order_data.get('provider')}")
print(f"Paid TRX: {order_data.get('paidTRX')}")
print(f"Expiry: {order_data.get('expiry')}")
else:
print(f"Error: {message}")
else:
print(f"Error: {response.status_code}")
print(response.text)
except Exception as e:
print(f"An error occurred: {str(e)}")
# Response
The response includes details about the energy delegation order, such as the order ID, the payment amount, and the expiration time.
# Success Response Parameters
Parameter | Type | Description |
---|---|---|
detail | object | Container for the response details |
detail.code | integer | Response code (10000 for success) |
detail.msg | string | Response message |
detail.data | object | Container for the response data |
detail.data.provider | string | The service provider used for energy delegation |
detail.data.orderId | string | The unique identifier for this order |
detail.data.balance | number | Your account balance before deduction |
detail.data.paidTRX | number | The amount of TRX deducted for this order |
detail.data.hash | array | Transaction hash(es) associated with this order |
detail.data.request_id | integer | Internal request ID |
detail.data.expiry | string | Expiration time of the energy delegation (in "YYYY-MM-DD HH:MM:SS" format) |
# Success Response Example
{
"detail": {
"code": 10000,
"msg": "Successfully delegated 64000 energy, 12.25 TRX deducted",
"data": {
"provider": "energy_provider",
"orderId": "ORD987654321",
"balance": 100.5,
"paidTRX": 12.25,
"hash": ["0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"],
"request_id": 10584,
"expiry": "2025-04-24 12:09:18"
}
}
}
# Error Responses
Status Code | Error Code | Description |
---|---|---|
400 | -10 | Minimum energy amount is 32,000 |
400 | -11 | Maximum energy amount is 131,000 |
400 | -2 | Not enough local balance |
400 | -3 | TRON transaction failed |
400 | -12 | All delegation attempts failed |
401 | -1 | Invalid API key or IP not in whitelist |
403 | -2 | Your IP address is not whitelisted |
429 | -1 | Too many requests (rate limited) |
# Error Response Examples
{
"detail": {
"code": -10,
"msg": "Minimum energy amount is 32,000",
"data": {}
}
}
{
"detail": {
"code": -2,
"msg": "Not enough local balance. Required: 12.25, Available: 5.5",
"data": {}
}
}
{
"detail": {
"code": -1,
"msg": "Invalid API key or IP not in whitelist",
"data": {}
}
}
# Notes
- The energy delegation is valid for exactly 1 hour from the time of the order.
- The cost of the energy delegation varies based on the current market price and the time of day.
- The system will automatically optimize your order for the best pricing and service quality.
- Energy amounts must be between 32,000 and 131,000.
- If you need more energy, consider placing multiple orders or using a longer-term delegation.