Skip to content

获取 /apiv2/prices

获取全天不同时间段的当前能量租赁价格。

端点 URL

GET https://netts.io/apiv2/prices

请求头

HeaderRequiredDescription
X-API-KEYYesYour API key
X-Real-IPYesIP address from whitelist

请求参数

无需参数 - 返回所有当前价格信息。

示例请求

cURL

bash
curl -X GET https://netts.io/apiv2/prices \
  -H "X-API-KEY: your_api_key" \
  -H "X-Real-IP: your_whitelisted_ip"

Python

python
import requests

url = "https://netts.io/apiv2/prices"
headers = {
    "X-API-KEY": "your_api_key",
    "X-Real-IP": "your_whitelisted_ip"
}

response = requests.get(url, headers=headers)
data = response.json()

if response.status_code == 200:
    print(f"Status: {data.get('status')}")
    print(f"Current UTC time: {data.get('current_utc_time')}")
    print(f"Active period: {data.get('active_period')}")
    print(f"Host price: {data.get('host_price')} TRX")
    
    print("\nPrice periods:")
    for period in data.get('periods', []):
        is_active = period.get('is_active', False)
        active_marker = " *ACTIVE*" if is_active else ""
        print(f"\n{period.get('label')}{active_marker}:")
        print(f"  Time: {period.get('period')}")
        
        prices = period.get('prices', {})
        print(f"  < 200k energy: {prices.get('less_than_200k', {}).get('price_sun')} sun")
        print(f"  = 131k energy: {prices.get('equal_131k', {}).get('price_sun')} sun")  
        print(f"  > 200k energy: {prices.get('more_than_200k', {}).get('price_sun')} sun")
else:
    print(f"Error: {data.get('message', 'Unknown error')}")

响应

成功响应 (200 OK)

json
{
    "status": "success",
    "current_utc_time": "2025-09-02 06:50:39",
    "current_utc_hour": 6,
    "active_period": "05:00-07:00",
    "last_update": "2025-09-02 08:05:03",
    "host_price": 2.989,
    "periods": [
        {
            "label": "Early Morning Hours (05:00-07:00 UTC)",
            "period": "05:00-07:00",
            "is_active": true,
            "prices": {
                "less_than_200k": {
                    "price_sun": 17
                },
                "equal_131k": {
                    "price_sun": 17
                },
                "more_than_200k": {
                    "price_sun": 17
                }
            }
        },
        {
            "label": "Morning Hours (07:00-11:00 UTC)",
            "period": "07:00-11:00",
            "is_active": false,
            "prices": {
                "less_than_200k": {
                    "price_sun": 17
                },
                "equal_131k": {
                    "price_sun": 17
                },
                "more_than_200k": {
                    "price_sun": 17
                }
            }
        }
    ]
}

响应字段

FieldTypeDescription
statusstringAlways "success" for successful requests
current_utc_timestringCurrent server time in UTC
current_utc_hourintegerCurrent UTC hour (0-23)
active_periodstringCurrently active pricing period
last_updatestringLast time prices were updated
host_pricenumberCurrent host price in TRX
periodsarrayArray of all pricing periods
periods[].labelstringHuman-readable period name
periods[].periodstringTime range (HH:MM-HH:MM)
periods[].is_activebooleanWhether this period is currently active
periods[].prices.less_than_200k.price_sunintegerPrice in SUN for energy < 200,000 units
periods[].prices.equal_131k.price_sunintegerPrice in SUN for exactly 131,000 units
periods[].prices.more_than_200k.price_sunintegerPrice in SUN for energy > 200,000 units

能量数量类别

CategoryDescriptionEnergy Range
less_than_200kSmall orders< 200,000 energy units
equal_131kStandard ordersExactly 131,000 energy units
more_than_200kLarge orders> 200,000 energy units

时间段

API返回5个不同时间段的价格:

PeriodTime Range (UTC)Description
Early Morning05:00-07:00Lower demand period
Morning07:00-11:00Business hours start
Daytime11:00-21:00Peak business hours
Evening21:00-23:00Evening activity
Night23:00-05:00Lowest demand period

速率限制

以下速率限制适用于此端点(每个 IP 地址):

PeriodLimitDescription
1 minute1 requestMaximum 1 request per minute
1 hour60 requestsMaximum 60 requests per hour

速率限制报头

http
RateLimit-Limit: 1
RateLimit-Remaining: 0
RateLimit-Reset: 21
X-RateLimit-Limit-Minute: 1
X-RateLimit-Remaining-Minute: 0
X-RateLimit-Limit-Hour: 60
X-RateLimit-Remaining-Hour: 59
Retry-After: 21

速率限制已超出 (429)

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

错误响应

身份验证错误 (401)

json
{
    "status": "error",
    "code": 401,
    "message": "Invalid API key or IP not in whitelist"
}

内部服务器错误 (500)

json
{
    "status": "error",
    "message": "Internal server error"
}

备注

  • No request body required - this is a GET request
  • All prices are in SUN (1 TRX = 1,000,000 SUN)
  • Prices vary by energy amount and time of day (UTC)
  • Active period: Changes throughout the day based on demand
  • Rate limiting: Strict limits due to database-intensive operations
  • Price updates: Prices are refreshed from database periodically
  • Time zones: All times are in UTC