Skip to content

POST /apiv2/order1h

Cree un pedido de alquiler de energía de 1 hora a través de múltiples proveedores de energía con conmutación por error automática.

URL del Punto Final

POST https://netts.io/apiv2/order1h

Encabezados de la solicitud

HeaderRequiredDescription
Content-TypeYesapplication/json
X-API-KEYYesYour API key from Netts dashboard
X-Real-IPYesIP address from your whitelist

Cuerpo de la solicitud

json
{
    "amount": 131000,
    "receiveAddress": "TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE"
}

Parámetros

ParameterTypeRequiredDescription
amountintegerYesEnergy amount to rent (minimum: 61000, maximum: 5000000)
receiveAddressstringYesTRON address that will receive the energy (TRC-20 format)

Selección del Proveedor

La API selecciona automáticamente el proveedor de energía óptimo en función de:

  • Cost efficiency - Always finds the lowest available price
  • Availability - Ensures sufficient energy reserves
  • Reliability - Uses providers with high success rates
  • Speed - Prioritizes fastest delivery times

Ejemplos de Solicitudes

cURL

bash
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": 131000,
    "receiveAddress": "TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE"
  }'

Python

python
import requests

url = "https://netts.io/apiv2/order1h"
headers = {
    "Content-Type": "application/json",
    "X-API-KEY": "your_api_key",
    "X-Real-IP": "your_whitelisted_ip"
}

payload = {
    "amount": 131000,
    "receiveAddress": "TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE"
}

response = requests.post(url, headers=headers, json=payload)
data = response.json()

if response.status_code == 200:
    detail = data.get('detail', {})
    order_data = detail.get('data', {})
    print(f"Order ID: {order_data.get('orderId')}")
    print(f"Transaction Hash: {order_data.get('hash')}")
    print(f"Energy Delivered: {order_data.get('energy')}")
    print(f"Cost: {order_data.get('paidTRX')} TRX")
    print(f"Delegate Address: {order_data.get('delegateAddress')}")
else:
    error_detail = data.get('detail', data)
    print(f"Error Code: {error_detail.get('code', 'N/A')}")
    print(f"Error Message: {error_detail.get('msg', error_detail)}")

Respuesta

Respuesta exitosa (200 OK)

json
{
    "detail": {
        "code": 10000,
        "msg": "Successful, 2.23 TRX deducted",
        "data": {
            "orderId": "1H123456",
            "paidTRX": 2.23,
            "hash": "a1b2c3d4e5f6789...",
            "delegateAddress": "TDelegatePoolAddress...",
            "energy": 131050
        }
    }
}

Campos de Respuesta

FieldTypeDescription
detail.codeintegerAlways 10000 for successful orders
detail.msgstringSuccess message with deducted amount
detail.data.orderIdstringUnified order ID (format: 1H{request_id})
detail.data.paidTRXnumberTotal cost in TRX (includes activation fee if address was not activated)
detail.data.hashstringTransaction hash (may be empty if provider doesn't provide it)
detail.data.delegateAddressstringPool address that delegated energy
detail.data.energyintegerEnergy amount + buffer (typically +50)

Respuestas de Error

Error de Autenticación (401)

json
{
    "detail": "Invalid API key or IP not in whitelist"
}

Saldo Insuficiente (403)

json
{
    "code": 1004,
    "msg": "Insufficient funds. Required: 2.23 TRX, Available: 1.50 TRX"
}

Servicio No Disponible (503)

json
{
    "code": 5003,
    "msg": "Service temporarily unavailable. All energy providers are currently unavailable."
}

Errores del Proveedor (503)

json
{
    "code": 5001,
    "msg": "Energy provider temporarily unavailable"
}
json
{
    "code": 5002,
    "msg": "Energy provider temporarily unavailable"
}
json
{
    "code": 5004,
    "msg": "Energy provider requires higher minimum amount"
}

Error interno del servidor (500)

json
{
    "code": 5000,
    "msg": "Internal server error occurred"
}

Referencia de Códigos de Error

CodeDescriptionHTTP Status
10000Success200
1004Insufficient balance403
5000Internal server error500
5001Energy provider unavailable503
5002Energy provider unavailable503
5003Energy service unavailable503
5004Energy provider minimum not met503

Límites de Tasa

Los siguientes límites de velocidad se aplican a este punto final (por dirección IP):

PeriodLimitDescription
1 second50 requestsMaximum 50 requests per second

Encabezados de Límite de Tasa

http
RateLimit-Limit: 50
RateLimit-Remaining: 49
RateLimit-Reset: 1
X-RateLimit-Limit-Second: 50
X-RateLimit-Remaining-Second: 49

Límite de Tasa Superado (429)

json
{
    "message": "API rate limit exceeded"
}

Notas

  • Energy is delivered instantly upon successful order (typically within 0.5-10 seconds)
  • API response timeout: Maximum 10 seconds, typically responds in up to 2 seconds
  • Address activation: If receiver address is not activated, Netts activates it at cost price
  • Activation delay: For non-activated addresses, API response may take up to 6 seconds due to activation process
  • Orders are processed 24/7 with automatic provider failover
  • Minimum energy amount: 61,000 units
  • Maximum energy amount: 5,000,000 units per order
  • Energy buffer: +50 units added automatically for provider compensation (free of charge)
  • Transaction hash: May be empty in response if energy provider doesn't provide delegation hash
  • Provider selection: Automatic based on cost and availability
  • Order ID format: 1H{request_id} for unified tracking
  • Pricing: Dynamic based on time of day and energy amount
  • Duration: Fixed 1 hour (3600 seconds)
  • Rate limiting: 50 requests per second per IP address