Quick Start
1. Activate API UserActivate the account, deposit funds, configure the IP whitelist, and get Base URL and API Key from API User in the WebApp or Telegram Bot.
2. Configure CallbackSet a public noticeUrl in API User settings. The system sends deposit and order status updates by HTTP POST.
3. Quote FirstCall POST /v1/quote/precount to get the fee, energy amount, and receiver activation status for this order.
4. Create Order or SubscriptionUse POST /v1/energy-rental/orders for one-time rental, or POST /v1/auto-energy/subscriptions for continuous Auto Energy. Later order results can be received through callbacks.
V1 price rule: /v1/quote/precount shows the current quote only. The server recalculates price when the order is submitted and processes the order at the latest quote. For batch orders, use finalFeeSun as the authoritative total.
Recommended Workflow
# Configure noticeUrl and IP whitelist in API User settings first
GET /v1/swap/info # TRX/USDT reference rate, quote time, limits, fees, and swap address
GET /v1/myInfo
POST /v1/quote/precount
POST /v1/energy-rental/orders
GET /v1/orders/{id}
# or
GET /v1/orders/getByOrderNo?orderNo=EXT-20260516001
GET /v1/tasks/{taskId} # query address activation progress
# Auto Energy
GET /v1/auto-energy/subscription-quote
POST /v1/auto-energy/subscriptions
GET /v1/auto-energy/subscriptions
GET /v1/auto-energy/subscriptions/{id}
POST /v1/auto-energy/subscriptions/{id}/close
API User requests require x-api-key, and the caller server IP must match the API User IP whitelist. Money fields use SUN. 1 TRX = 1,000,000 SUN. After noticeUrl is configured, deposit credits, order success, and order failure are pushed asynchronously to that callback URL. Keep order query endpoints as compensation checks.
Auth and Limits
Except for the GET /v1 version check, every V1 endpoint requires the x-api-key request header and the caller IP must be in the API User IP whitelist. Do not put the API Key in the query string or request body.
| Item | Description |
|---|
| Read rate limit | Counted by API Key + endpoint path. Default: up to 30 requests per 10 seconds. |
| Write rate limit | Order creation and subscription creation are counted by API Key + endpoint path. Default: up to 10 requests per 10 seconds. |
| Subscription detail and close | GET /v1/auto-energy/subscriptions/{id} and POST /v1/auto-energy/subscriptions/{id}/close have no separate endpoint rate limit, but API Key, IP whitelist, and block checks still apply. |
| Error blocking | If user-correctable request errors, including request/access errors and insufficient balance, exceed the configured threshold in the last 7 days, the API returns API_USER_BLOCKED. This general penalty clears on the next API request after the recent count falls to or below the threshold; an administrator can also unblock it. Three cross-account access violations within 10 minutes trigger a security block that only an administrator can lift. |
| Errors not counted for blocking | INVALID_PRICE_CONFIG, INSUFFICIENT_PLATFORM_ENERGY_CAPACITY, TRX_NEEDED_UNAVAILABLE, TIMEOUT, and INTERNAL_ERROR are service-side or platform-side reasons and do not count toward API User error blocking. |
| Callback acceptance | Callback requests currently do not include an additional signature header. Use HTTPS and an unguessable callback path or token parameter. For Auto Energy, deduplicate by eventType + chargeId, or eventType + subscriptionId when chargeId is null. |
Callback Notifications
Configure noticeUrl from API User settings in the WebApp or Telegram Bot. The URL must start with http:// or https:// and resolve to public addresses. If it is empty, no HTTP callback notification is created. Use the final receiving URL that returns 2xx; HTTP redirects are not followed.
Delivery rule: the system sends an HTTP POST request with application/json;charset=UTF-8. Any 2xx HTTP status is treated as success. Non-2xx responses, timeouts, or network errors are recorded as failures and retried according to system retry settings. Each delivery round that exhausts its short retries adds one cumulative failure; success does not clear the count. Delivery is suspended when the current URL exceeds the configured limit (default 20), with one suspension alert to the user and administrator. Changing to a different URL or an administrator resetting the count restores future delivery. Historical callbacks are not replayed automatically.
| Scenario | type | Description |
|---|
| Deposit credited | deposit | TRX was received by the user's deposit address and credited to the account. |
| Order status changed | order | Energy order success, failure, or completion. Managed Auto Energy allocations are excluded from ordinary order callbacks. |
| Auto Energy lifecycle or billing | autoEnergy | Start, replenishment, overnight charge, closing, failure, and closed events. |
Order callbacks use one public payload format and include callbackStatus, hash, hashes, and activation. activation has a value only when the order was created after automatic address activation and this callback is for the final energy order; otherwise it is null. Use type to distinguish callback types. Deposit and order callbacks use their record/order identity; Auto Energy uses eventType + chargeId, or eventType + subscriptionId when no charge exists.
Deposit Callback Example
{
"type": "deposit",
"id": 456,
"userId": 1,
"address": "T9z6yrJXuiJpfWhis3Ae9nHK7k65yM5AHP",
"fromAddress": "TQ8r...",
"amount": 10000000,
"txHash": "9c4f...",
"createdAt": "2026-05-16T12:00:00"
}
Deposit Callback Fields
| Field | Meaning |
|---|
type | Callback type. Deposit callbacks always use deposit. |
id | Deposit record ID. Use it for idempotency. |
userId | System user ID of the API User. |
address | API User deposit address in Base58Check format. |
fromAddress | On-chain sender address in Base58Check format. |
amount | Credited amount in SUN. |
txHash | Deposit transaction hash. |
createdAt | Deposit record creation time. |
Order Callback Example
{
"type": "order",
"id": 123,
"orderNo": "EXT-20260516001",
"orderTime": 3600,
"orderType": 0,
"paidAmount": 1500000,
"receiverAddress": "TJqiMSSmRtm4LvXrYBWysz9DnNrFQDaBv9",
"resourceAmount": 65000,
"resourceType": 1,
"status": 1,
"callbackStatus": "SUCCESS",
"failReason": null,
"activation": null,
"hash": "ab12...",
"hashes": [
"ab12..."
],
"timeStamp": 1778918400000,
"times": 1,
"totalFee": 1500000,
"updatedAt": "2026-05-16 12:00:00",
"subscription": null
}
| Field | Meaning |
|---|
type | Callback type. Order status callbacks always use order. |
id | System order ID. Use it for idempotency. |
orderNo | External order number submitted when creating the order. It may be null when omitted. |
orderTime | Rental duration in seconds. |
orderType | Order type. |
paidAmount | Actual paid or frozen amount in SUN. Failed-order refunds use this field. |
receiverAddress | TRON Base58Check address receiving the resource. |
resourceAmount | Delegated energy amount. |
resourceType | Resource type. Energy orders currently use 1. |
status | 0=pending, 1=delegated, 2=completed, 3=delegating, -1=failed, -2=refunded. |
callbackStatus | SUCCESS=the purchase is successful; FAILED=the order failed; PENDING=pending; UNKNOWN=other processing state. |
failReason | Public failure reason. It is null on success. User-actionable reasons are returned as-is; service-side reasons are returned as 服务端错误. |
activation | Address activation information attached to this order. null for normal orders or orders without address activation. |
activation.taskId | Address activation ID, used for idempotency and activation progress lookup. |
activation.status | Overall address activation status. |
activation.failReason | Activation failure reason. null while processing or on success. |
activation.currentStep | Current activation step. |
activation.activationStatus | On-chain address activation transaction status. |
activation.feeSun | Address activation fee in SUN. |
activation.paidAmountSun | Actual activation amount charged in SUN. |
activation.paidAmountTrx | Actual activation amount charged in TRX. |
activation.txHash | Address activation transaction hash. null when not submitted or unavailable. |
hash | First on-chain transaction hash for this resource delivery, or null when unavailable. |
hashes | All on-chain transaction hashes for this resource delivery. Empty when no transaction hash is available. |
timeStamp | Order creation timestamp in milliseconds. |
times | Transfer count. |
totalFee | Order amount in SUN. For direct-transfer overpayments, this is the matched quote amount; see paidAmount for the actual paid amount. |
updatedAt | Last order update time. |
Auto Energy Callback Example
{
"type": "autoEnergy",
"eventType": "AUTO_ENERGY_REPLENISHED",
"subscriptionId": 18,
"receiverAddress": "TJqiMSSmRtm4LvXrYBWysz9DnNrFQDaBv9",
"status": "ACTIVE",
"targetEnergy": 131000,
"smallTierMinimumAvailableEnergy": 64805,
"chargedTierEnergy": 65000,
"feeSun": 14000000,
"chargeId": 72,
"chargeType": "USAGE_TOPUP",
"chargeStatus": "SETTLED",
"coverageEndsAt": "2026-08-28T12:00:00",
"failReason": null,
"hashes": ["ab12..."],
"timeStamp": 1787918400000
}
eventType is one of AUTO_ENERGY_STARTED, AUTO_ENERGY_REPLENISHED, AUTO_ENERGY_OVERNIGHT_CHARGED, AUTO_ENERGY_OVERNIGHT_REFUNDED, AUTO_ENERGY_CLOSING, AUTO_ENERGY_FAILED, or AUTO_ENERGY_CLOSED. AUTO_ENERGY_OVERNIGHT_REFUNDED means earlier Energy usage was detected after overnight settlement and that overnight fee was returned. Deduplicate charge events by eventType + chargeId; when chargeId is null, use eventType + subscriptionId. targetEnergy is the managed target, and actual available Energy may vary within ±0.3%.
Endpoints
Returns the current API version for connectivity checks. This value comes from https://api.trxforgas.com/v1.
API_BASE_URL="<copy from API User in the WebApp or Telegram Bot>"
curl "$API_BASE_URL/v1"
{
"version": "x.y.z"
}Response Fields
| Field | Meaning |
|---|
version | Current API service version. |
GET/v1/swap/info
Swap, auth required
Returns TRX/USDT swap reference information, including the current reference rate, quote time, single-transfer limits, fee rules, and enabled on-chain swap address. This endpoint is for API Users to display swap information in their own pages or systems; it is not an order endpoint.
curl --request GET \
--url "$API_BASE_URL/v1/swap/info" \
--header 'x-api-key: <YOUR_API_KEY>'
{
"result": "SUCCESS",
"quote": {
"available": true,
"quoteTime": "2026-06-13T12:00:00Z",
"quoteAt": "2026-06-13T12:00:00Z",
"nextRefreshAt": "2026-06-13T12:01:00Z",
"refreshIntervalSeconds": 60,
"oneUsdtToTrx": "3.2",
"usdtToTrxInput": "5",
"usdtToTrxReferenceOutput": "16",
"hundredTrxToUsdt": "31.25",
"trxToUsdt": {
"enabled": true,
"direction": "TRX_TO_USDT",
"inputToken": "TRX",
"outputToken": "USDT",
"minInput": "10",
"maxInput": "5000",
"feeBps": 30,
"feePercent": "0.3",
"feeDeductionMode": "BEFORE_SWAP",
"feeToken": "TRX",
"minFee": "1"
},
"usdtToTrx": {
"enabled": true,
"direction": "USDT_TO_TRX",
"inputToken": "USDT",
"outputToken": "TRX",
"minInput": "5",
"maxInput": "3000",
"feeBps": 30,
"feePercent": "0.3",
"feeDeductionMode": "BEFORE_SWAP",
"feeToken": "USDT",
"minFee": "0.5"
},
"address": "TSwapAddress",
"addresses": [
"TSwapAddress"
]
},
"reason": null,
"message": null
}Response Fields
| Field | Meaning |
|---|
quote.available | Whether a displayable reference rate and enabled swap address are currently available. |
quote.quoteTime | Time when this reference quote was fetched, in ISO-8601 UTC format. Display this time together with the rate when showing the quote. |
quote.quoteAt | Same value as quoteTime, kept for existing display code. |
quote.nextRefreshAt | Next scheduled refresh time for the reference rate. |
quote.refreshIntervalSeconds | Recommended refresh interval. Currently 60 seconds. |
quote.oneUsdtToTrx | Reference TRX amount normalized to 1 USDT. |
quote.usdtToTrxInput | Actual USDT input used for the USDT → TRX reference quote. The minimum input is used when it exceeds 1 USDT. |
quote.usdtToTrxReferenceOutput | Reference TRX output corresponding to usdtToTrxInput. |
quote.hundredTrxToUsdt | Reference USDT amount for 100 TRX. |
quote.trxToUsdt | TRX to USDT enable flag, input/output tokens, single-transfer input limits, and fee rules. |
quote.usdtToTrx | USDT to TRX enable flag, input/output tokens, single-transfer input limits, and fee rules. |
quote.*.feeBps | Fee rate in basis points; 100 basis points equals 1%. |
quote.*.feePercent | Formatted fee percentage value without the percent sign. |
quote.*.feeDeductionMode | BEFORE_SWAP deducts the fee from the input token before swapping; AFTER_SWAP deducts it from the output token after swapping. |
quote.*.feeToken | Token in which the fee is charged. |
quote.*.minFee | Minimum fee for the direction, denominated in feeToken. |
quote.address | First enabled on-chain swap address, convenient for display or copy. |
quote.addresses | All enabled swap addresses. |
Returns API User available balance, dedicated deposit address, and masked API Key.
curl --request GET \
--url "$API_BASE_URL/v1/myInfo" \
--header 'x-api-key: <YOUR_API_KEY>'
{
"result": "SUCCESS",
"account": {
"id": 1,
"name": "Demo API User",
"avaliableBalance": 10000000,
"addressForDeposit": "T9z6yrJXuiJpfWhis3Ae9nHK7k65yM5AHP",
"apiKeyMasked": "abcd...wxyz",
"noticeUrl": "",
"createdAt": "2026-05-16T12:00:00",
"updatedAt": "2026-05-16T12:00:00"
},
"reason": null,
"message": null
}
| Field | Meaning |
|---|
id | System user ID of the API User. |
name | API User name. |
avaliableBalance | Available balance in SUN. |
addressForDeposit | Dedicated API User deposit address in Base58Check format. |
apiKeyMasked | Masked API Key, used only to identify the current key. |
noticeUrl | Configured HTTP callback URL. Empty string when not configured. |
createdAt | API User creation time. |
updatedAt | Last API User update time. |
POST/v1/quote/precount
Quote
Returns estimated energy, fee, rental duration, and receiver status for this order. This endpoint does not lock price. For batch orders, use finalFeeSun as the authoritative total.
| Field | Required | Type | Description |
|---|
times | yes | int | Purchase quantity. Must be a positive integer within the configured per-order limit (20 by default). |
receiverAddress | yes | string | TRON Base58Check address that receives the delegated energy. |
energyType | no | string | activated or noActivated. Defaults to activated. activated uses 65000 energy per transfer, and noActivated uses 131000 energy per transfer; activated × 2 = 130000 and noActivated × 1 = 131000 are different order types. |
durationHours | no | int | Whole-hour rental duration. Defaults to 1. Supported values: 1, 4, 8, 24. |
autoActivate | no | boolean | Defaults to false. When true, the server checks the receiver first. Only inactive addresses add an activation fee estimate; already active addresses return activationFeeSun=0. finalFeeSun still means energy fee only. |
curl --request POST \
--url "$API_BASE_URL/v1/quote/precount" \
--header 'x-api-key: <YOUR_API_KEY>' \
--header 'Content-Type: application/json' \
--data '{
"times": 1,
"receiverAddress": "TJqiMSSmRtm4LvXrYBWysz9DnNrFQDaBv9",
"energyType": "activated",
"durationHours": 1,
"autoActivate": true
}'{
"result": "SUCCESS",
"quote": {
"valid": true,
"reason": null,
"receiverAddress": "TJqiMSSmRtm4LvXrYBWysz9DnNrFQDaBv9",
"addressValid": true,
"addressActivated": true,
"energyType": "activated",
"times": 1,
"durationSeconds": 3600,
"durationHours": 1,
"energyAmount": 65000,
"finalFeeSun": 1500000,
"finalFeeTrx": "1.5",
"autoActivate": true,
"needActivation": false,
"activationFeeSun": 0,
"activationFeeTrx": "0",
"estimatedTotalFeeSun": 1500000,
"estimatedTotalFeeTrx": "1.5"
},
"reason": null,
"message": null
}
| Field | Meaning |
|---|
valid | Whether the quote is valid. If false, check reason. |
reason | Quote failure reason. null when the quote succeeds. |
receiverAddress | Requested TRON Base58Check address receiving the resource. |
addressValid | Whether the receiver address format is valid. |
addressActivated | Whether the receiver address is currently activated. |
energyType | Energy type used for the quote: activated or noActivated. |
times | Transfer count used for this quote. |
durationSeconds | Rental duration in seconds. |
durationHours | Rental duration in hours. Supported values: 1, 4, 8, 24. |
energyAmount | Estimated delegated energy amount. |
finalFeeSun | Estimated energy order fee in SUN. Does not include activation fee. |
finalFeeTrx | Estimated energy order fee in TRX. Does not include activation fee. |
autoActivate | Whether this request asks the server to auto-activate an inactive address. |
needActivation | Whether this request needs address activation first. |
activationFeeSun | Estimated activation fee in SUN. Greater than 0 only when needActivation=true. |
activationFeeTrx | Estimated activation fee in TRX. |
estimatedTotalFeeSun | Estimated total fee in SUN: energy fee plus possible activation fee. This does not lock the price. |
estimatedTotalFeeTrx | Estimated total fee in TRX. This does not lock the price. |
POST/v1/energy-rental/orders
Create order
Creates an energy rental order. The server recalculates the quote and deducts API User available balance at the current price.
| Field | Required | Type | Description |
|---|
times | yes | int | Purchase quantity. Must be a positive integer within the configured per-order limit (20 by default). |
receiverAddress | yes | string | TRON Base58Check address that receives the delegated energy. |
orderNo | yes | string | External order number. Must be unique for the same API User. |
energyType | yes | string | activated or noActivated. activated uses 65000 energy per transfer, and noActivated uses 131000 energy per transfer; activated × 2 = 130000 and noActivated × 1 = 131000 are different order types. |
durationHours | no | int | Whole-hour rental duration. Defaults to 1. |
autoActivate | no | boolean | Defaults to false. Whether to auto-activate an inactive receiver address. If omitted or false, inactive addresses return the original error. Even when set to true, an activation task and activation fee are used only when the receiver is inactive. |
When autoActivate=true and the receiver is inactive, the order.activation field contains address activation information. Query progress with GET /v1/tasks/{taskId}. If the receiver is already active, no activation is created, no activation fee is frozen or charged, and the response keeps the normal order shape.
curl --request POST \
--url "$API_BASE_URL/v1/energy-rental/orders" \
--header 'x-api-key: <YOUR_API_KEY>' \
--header 'Content-Type: application/json' \
--data '{
"times": 1,
"orderNo": "EXT-20260516001",
"receiverAddress": "TJqiMSSmRtm4LvXrYBWysz9DnNrFQDaBv9",
"energyType": "activated",
"durationHours": 1,
"autoActivate": true
}'{
"result": "ACCEPTED",
"order": {
"id": 123,
"orderNo": "EXT-20260516001",
"orderTime": 3600,
"orderType": 0,
"paidAmount": 1500000,
"receiverAddress": "TJqiMSSmRtm4LvXrYBWysz9DnNrFQDaBv9",
"resourceAmount": 65000,
"resourceType": 1,
"status": 0,
"failReason": null,
"timeStamp": 1778918400000,
"times": 1,
"totalFee": 1500000,
"updatedAt": "2026-05-16 12:00:00",
"activation": null,
"subscription": null
},
"reason": null,
"message": null
}
order Response Fields
order.activation contains address activation information attached to this order. It is null for normal orders. When autoActivate=true and the receiver address is inactive, the create endpoint first returns the order request with activation; before the real energy order is created, real order fields such as id, paidAmount, and totalFee are null.
| Field | Meaning |
|---|
id | System order ID. null before the real energy order is created after activation. |
orderNo | External order number submitted when creating the order. Unique under the same API User. |
orderTime | Rental duration in seconds. |
orderType | Order type. Energy rental orders currently use 0; null before the real order is created. |
paidAmount | Actual paid or frozen amount in SUN. null before the real order is created. |
receiverAddress | TRON Base58Check address receiving the resource. |
resourceAmount | Delegated energy amount. null before the real order is created. |
resourceType | Resource type. Energy orders currently use 1. |
status | 0=pending, 1=delegated, 2=completed, 3=delegating, -1=failed, -2=refunded. null before the real order is created. |
failReason | Failure reason. null when successful or still processing. |
timeStamp | Order creation timestamp in milliseconds. null before the real order is created. |
times | Transfer count. |
totalFee | Order amount in SUN. For direct-transfer overpayments, this is the matched quote amount; see paidAmount for the actual paid amount. null before the real order is created. |
updatedAt | Last order update time. null before the real order is created. |
activation | Address activation information. null for normal orders. |
activation.taskId | Address activation ID for progress lookup. |
activation.status | Overall address activation status. |
activation.failReason | Activation failure reason. null while processing or on success. |
activation.currentStep | Current activation step. |
activation.activationStatus | On-chain address activation transaction status. |
activation.feeSun | Address activation fee in SUN. |
activation.feeTrx | Address activation fee in TRX. |
activation.paidAmountSun | Charged activation amount in SUN. |
activation.paidAmountTrx | Charged activation amount in TRX. |
activation.txHash | Address activation transaction hash. null when not submitted or unavailable. |
activation.energyOrderId | Energy order ID created after activation. null before it is created. |
activation.autoEnergySubscriptionId | Auto Energy subscription ID created after activation. null before it is created or when not applicable. |
GET/v1/orders/{id}
Order lookup
Queries an order by the platform order ID. Only the current API User's own orders can be queried.
curl --request GET \
--url "$API_BASE_URL/v1/orders/123" \
--header 'x-api-key: <YOUR_API_KEY>'
{
"result": "SUCCESS",
"order": {
"id": 123,
"orderNo": "EXT-20260516001",
"orderTime": 3600,
"orderType": 0,
"paidAmount": 1500000,
"receiverAddress": "TJqiMSSmRtm4LvXrYBWysz9DnNrFQDaBv9",
"resourceAmount": 65000,
"resourceType": 1,
"status": 1,
"failReason": null,
"timeStamp": 1778918400000,
"times": 1,
"totalFee": 1500000,
"updatedAt": "2026-05-16 12:00:00",
"activation": null,
"subscription": null
},
"reason": null,
"message": null
}Order Response Fields
| Field | Meaning |
|---|
id | System order ID. |
orderNo | External order number submitted when creating the order. Unique under the same API User. |
orderTime | Rental duration in seconds. |
orderType | Order type. Energy rental orders currently use 0. |
paidAmount | Actual paid or frozen amount in SUN. Failed-order refunds use this field. |
receiverAddress | TRON Base58Check address receiving the resource. |
resourceAmount | Delegated energy amount. |
resourceType | Resource type. Energy orders currently use 1. |
status | 0=pending, 1=delegated, 2=completed, 3=delegating, -1=failed, -2=refunded. |
failReason | Public failure reason. null when the order succeeded or is still processing. |
timeStamp | Order creation timestamp in milliseconds. |
times | Transfer count. |
totalFee | Order amount in SUN. For direct-transfer overpayments, this is the matched quote amount; see paidAmount for the actual paid amount. |
updatedAt | Last order update time. |
activation | Address activation information attached to this order. null for regular orders or when no activation was created. |
activation.taskId | Address activation ID. Use it to query activation progress. |
activation.status | Overall address activation status. |
activation.failReason | Activation failure reason. null while processing or on success. |
activation.currentStep | Current activation step. |
activation.activationStatus | On-chain activation transaction status. |
activation.feeSun | Activation fee in SUN. |
activation.feeTrx | Activation fee in TRX. |
activation.paidAmountSun | Charged activation amount in SUN. |
activation.paidAmountTrx | Charged activation amount in TRX. |
activation.txHash | Activation transaction hash. null before submission or when unavailable. |
activation.energyOrderId | Energy order ID created after activation. null before it is created or when not applicable. |
activation.autoEnergySubscriptionId | Auto Energy subscription ID created after activation. null before it is created or when not applicable. |
GET/v1/orders/getByOrderNo
Order lookup
Queries an order by external order number. This fits integrations that only store their own orderNo.
curl --request GET \
--url "$API_BASE_URL/v1/orders/getByOrderNo?orderNo=EXT-20260516001" \
--header 'x-api-key: <YOUR_API_KEY>'
{
"result": "SUCCESS",
"order": {
"id": 123,
"orderNo": "EXT-20260516001",
"orderTime": 3600,
"orderType": 0,
"paidAmount": 1500000,
"receiverAddress": "TJqiMSSmRtm4LvXrYBWysz9DnNrFQDaBv9",
"resourceAmount": 65000,
"resourceType": 1,
"status": 1,
"failReason": null,
"timeStamp": 1778918400000,
"times": 1,
"totalFee": 1500000,
"updatedAt": "2026-05-16 12:00:00",
"activation": null,
"subscription": null
},
"reason": null,
"message": null
}Order Response Fields
| Field | Meaning |
|---|
id | System order ID. |
orderNo | External order number submitted when creating the order. Unique under the same API User. |
orderTime | Rental duration in seconds. |
orderType | Order type. Energy rental orders currently use 0. |
paidAmount | Actual paid or frozen amount in SUN. Failed-order refunds use this field. |
receiverAddress | TRON Base58Check address receiving the resource. |
resourceAmount | Delegated energy amount. |
resourceType | Resource type. Energy orders currently use 1. |
status | 0=pending, 1=delegated, 2=completed, 3=delegating, -1=failed, -2=refunded. |
failReason | Public failure reason. null when the order succeeded or is still processing. |
timeStamp | Order creation timestamp in milliseconds. |
times | Transfer count. |
totalFee | Order amount in SUN. For direct-transfer overpayments, this is the matched quote amount; see paidAmount for the actual paid amount. |
updatedAt | Last order update time. |
activation | Address activation information attached to this order. null for regular orders or when no activation was created. |
activation.taskId | Address activation ID. Use it to query activation progress. |
activation.status | Overall address activation status. |
activation.failReason | Activation failure reason. null while processing or on success. |
activation.currentStep | Current activation step. |
activation.activationStatus | On-chain activation transaction status. |
activation.feeSun | Activation fee in SUN. |
activation.feeTrx | Activation fee in TRX. |
activation.paidAmountSun | Charged activation amount in SUN. |
activation.paidAmountTrx | Charged activation amount in TRX. |
activation.txHash | Activation transaction hash. null before submission or when unavailable. |
activation.energyOrderId | Energy order ID created after activation. null before it is created or when not applicable. |
activation.autoEnergySubscriptionId | Auto Energy subscription ID created after activation. null before it is created or when not applicable. |
GET/v1/tasks/{taskId}
Activation lookup
Look up address activation progress. A taskId is returned inside activation only when you create an order or Auto Energy subscription with autoActivate and the receiver address is inactive. Already active addresses have no activation and no activation fee.
curl --request GET \
--url "$API_BASE_URL/v1/tasks/1001" \
--header 'x-api-key: <YOUR_API_KEY>'
{
"result": "SUCCESS",
"activation": {
"taskId": 1001,
"status": "PROCESSING",
"failReason": null,
"currentStep": "EXECUTE_ACTIVATION",
"activationStatus": "PROCESSING",
"feeSun": 1200000,
"feeTrx": "1.2",
"paidAmountSun": 0,
"paidAmountTrx": "0",
"txHash": null,
"energyOrderId": null,
"autoEnergySubscriptionId": null
},
"reason": null,
"message": null
}
GET/v1/auto-energy/subscription-quote
Auto Energy
Returns the current initial 131000-Energy fee, both refill tiers, and the independent overnight fee. Quotes do not lock prices.
curl --request GET \
--url "$API_BASE_URL/v1/auto-energy/subscription-quote" \
--header 'x-api-key: <YOUR_API_KEY>'
{
"result": "SUCCESS",
"quote": {
"targetEnergy": 131000,
"smallTierMinimumAvailableEnergy": 64805,
"initialFeeSun": 28000000,
"smallRefillFeeSun": 14000000,
"fullRefillFeeSun": 28000000,
"overnightFeeSun": 2000000
},
"reason": null,
"message": null
}
POST/v1/auto-energy/subscriptions
Auto Energy
Creates a persistent allocation toward a managed target of 131000 Energy. On-chain resource conversion is not exact, so actual available Energy may vary within ±0.3%. The delegation itself does not expire; each successful replacement starts a new 24-hour billing window.
Billing and replacement: after usage, 64805-130999 available Energy (inclusive) is billed at the 65000 tier; below 64805 is billed at the 131000 tier. The old allocation is reclaimed and the replacement amount is calculated toward the 131000 target (±0.3%). If the address remains idle for 24 hours, the allocation stays delegated and only the independent overnight fee is charged. Managed allocations are tracked separately from ordinary orders and use dedicated Auto Energy callbacks.
| Field | Required | Description |
|---|
receiverAddress | yes | TRON Base58Check receiver. |
maxInitialFeeSun | no | Cap for the initial 131000-Energy fee. |
maxOvernightFeeSun | no | Authorization cap for each overnight charge. |
autoActivate | no | Activate an inactive receiver first. |
clientTaskNo | no | Activation-task idempotency key. |
maxActivationFeeSun | no | Activation-fee cap. |
curl --request POST \
--url "$API_BASE_URL/v1/auto-energy/subscriptions" \
--header 'x-api-key: <YOUR_API_KEY>' \
--header 'Content-Type: application/json' \
--data '{
"receiverAddress": "TJqiMSSmRtm4LvXrYBWysz9DnNrFQDaBv9",
"maxInitialFeeSun": 30000000,
"maxOvernightFeeSun": 5000000,
"autoActivate": true,
"maxActivationFeeSun": 2000000
}'{
"result": "SUCCESS",
"subscription": {
"id": 18,
"receiverAddress": "TJqiMSSmRtm4LvXrYBWysz9DnNrFQDaBv9",
"status": "PENDING_ORDER",
"displayStatus": "PENDING_ORDER",
"targetEnergy": 131000,
"maxOvernightFeeSun": 5000000,
"currentDelegateHash": null,
"delegateHashes": [],
"lastChargeType": "INITIAL",
"lastChargeFeeSun": 28000000,
"currentOvernightFeeSun": 2000000,
"nextOvernightAt": null,
"activation": null
},
"reason": null,
"message": null
}
GET/v1/auto-energy/subscriptions
Auto Energy
List subscriptions, close them asynchronously, and inspect the independent charge ledger.
| Endpoint | Description |
|---|
GET /v1/auto-energy/subscriptions?page=1&pageSize=10 | List current-user subscriptions. |
GET /v1/auto-energy/subscriptions/{id} | Get one subscription. |
POST /v1/auto-energy/subscriptions/{id}/close | Move to CLOSING and reclaim asynchronously; the terminal status is CLOSED. |
GET /v1/auto-energy/subscriptions/{id}/billing-records?page=1&pageSize=10 | Recommended public-safe list of INITIAL, USAGE_TOPUP, and OVERNIGHT billing records. |
GET /v1/auto-energy/subscriptions/{id}/charges?page=1&pageSize=10 | Deprecated raw response retained only for compatibility with existing clients. |
Initial allocation and usage top-ups are priced with a fixed 86400-second (24-hour) quote; the overnight fee is configured separately. Responses include the fixed targetEnergy=131000, public delegation hashes, latest availability, next overnight deadline, and latest charge summary without exposing internal allocation IDs. Charge records include type, quoted Energy tier, fee, state, and coverage.
Web3 API · Direct on-chain payment
No account, login, API key, balance deposit or backend proxy is required. Get payment instructions, transfer from your wallet, then query the existing business result. These endpoints reuse the existing direct-transfer products.
Base URL: https://api.trxforgas.com · /web3/v1
Use this deployment’s asset IDs and contract addresses from options. Do not mix networks or send test assets to a production address. The public URL is available after this API version is deployed.
Existing business rules
- Energy: only the existing 1-hour direct-transfer packages. Quote does not create an order or lock a price. The existing incoming-payment rules determine the purchased package. A different beneficiary must be sent as payment.memo in the TRX transfer.
- Swap: TRX ↔ USDT on TRON. The quote is an estimate, not a guaranteed output. Output always returns to the actual payment wallet; a different receiver is rejected. No approval is required for the user’s ordinary transfer.
- Bridge: quote internally obtains a quote and confirms the existing order. Pay the exact returned amount and any required memo before expiresAt. Existing route availability, payer active-order limits, re-quoting and exception handling still apply. Unsupported memo/tag destination formats are not added by this API.
- Fees, delivery, refunds and manual support follow the current products. This API does not add guaranteed prices or automatic refunds. Wallet network fees are paid separately. Energy does not include Bandwidth.
GET /web3/v1/options
Returns assets, enabled services, energy packages, Swap pairs and available bridge routes. IDs are deployment-scoped chain:asset strings. Amounts use smallest-unit integer strings.
energy.packages[].packageId: activated-1h, noActivated-1h; durationSeconds = 3600.
POST /web3/v1/quote
Content-Type: application/json. Only supply fields belonging to the selected type. Other fields, including durationHours/durationSeconds, are rejected.
| type | Required fields | Optional fields |
| energy | payerAddress, packageId | receiverAddress |
| swap | payerAddress, fromAsset, toAsset, amount | receiverAddress (must equal payer) |
| bridge | payerAddress, fromAsset, toAsset, amount, receiverAddress | — |
{"type":"energy","payerAddress":"YOUR_TRON_ADDRESS","packageId":"activated-1h"}
{"type":"swap","payerAddress":"YOUR_TRON_ADDRESS","fromAsset":"tron:trx","toAsset":"tron:usdt","amount":"100000000"}
{"type":"bridge","payerAddress":"SOURCE_WALLET","fromAsset":"FROM_OPTIONS","toAsset":"FROM_OPTIONS","amount":"RAW_INTEGER","receiverAddress":"DESTINATION_WALLET"}
Response: payment (chain, asset, address, amount, optional memo), receive, included fee, priceLocked=false and rules. Energy/Swap return queryBy=paymentTxHash and no order id. Bridge returns queryBy=id, an opaque id and expiresAt (ISO 8601 with timezone); save the complete id.
Energy receive contains energyAmount and durationSeconds; Swap/bridge receive contains asset and estimatedAmount. Swap fee is already deducted in estimatedAmount. An unsuccessful quote does not return a payable address.
GET /web3/v1/status
/web3/v1/status?type=energy&paymentChain=tron&paymentTxHash=HASH
/web3/v1/status?type=swap&paymentChain=tron&paymentTxHash=HASH
/web3/v1/status?type=bridge&id=COMPLETE_ID_FROM_QUOTE
Querying a hash only reads an existing record; it does not submit or confirm payment. The scanner runs independently of the browser. Existing energy direct payments can also be queried; account-funded orders stay private. Multiple Swap events in one transaction return payments[], and each item has its own status.
| status | Meaning |
| not_found | Not indexed yet or no matching direct-transfer payment. Do not pay again. |
| waiting_payment | Bridge order awaiting payment. |
| processing | Payment detected, delivery still in progress. |
| completed | Existing business records indicate delivery completed. |
| settled | All matched events finished, with mixed delivery/refund results; inspect payments[]. |
| expired | Bridge payment window closed. |
| refunding / refunded | Existing refund in progress / recorded as completed. |
| attention_required | Needs review or support under existing rules; this is not a promise of automatic retry or refund. |
Response includes message, nextPollSeconds, paymentTxHash, chain-qualified resultTxHashes, receive and available refund/refunds records. Follow nextPollSeconds; 0 means stop polling. Save the wallet payment hash before closing the page.
Rate limits and browser access
No cookies or domain whitelist. Use fetch with credentials: omit. CORS supports GET/POST/OPTIONS. Per brand and real IP: 20 POST quote requests per 60 seconds; 120 other requests per 60 seconds (including preflight). Existing bridge payer limits also apply. HTTP 429 returns Retry-After: 60. Requests record IP, endpoint, HTTP status and elapsed time in the existing API statistics.
Errors use code/message: INVALID_REQUEST, UNSUPPORTED_FIELD, INVALID_PACKAGE, INVALID_AMOUNT, UNSUPPORTED_ASSET, RECEIVER_MUST_BE_PAYER, INVALID_QUERY (400); NOT_FOUND (404); SOURCE_ADDRESS_IN_USE / QUOTE_NEEDS_REFRESH (409); RATE_LIMITED (429); UNAVAILABLE (503). Do not retry payments to recover API errors. Existing access blocks may return HTTP 403 with error=request_blocked.
JavaScript
const base = 'https://api.trxforgas.com';
async function web3(path, body) {
const response = await fetch(base + '/web3/v1/' + path, {
method: body ? 'POST' : 'GET', credentials: 'omit',
headers: body ? { 'Content-Type': 'application/json' } : {},
body: body ? JSON.stringify(body) : undefined
});
const data = await response.json();
if (!response.ok) throw new Error(data.code + ': ' + data.message);
return data;
}
const options = await web3('options');
const energy = await web3('quote', { type: 'energy', payerAddress,
packageId: 'activated-1h' });
// Display energy.payment, then let the wallet send the transfer.
const result = await web3('status?' + new URLSearchParams({
type: 'energy', paymentChain: 'tron', paymentTxHash
}));
Download energy, Swap and bridge examples. Wallet signing is supplied by the integrating wallet; examples never send a payment automatically.
Error Codes
| Error Codes | Meaning |
|---|
INVALID_REQUEST | Request body, path parameter, query parameter, or JSON type is invalid. |
INVALID_API_KEY | Missing or invalid x-api-key. |
NOT_API_USER | The API Key does not belong to an API User account. |
USER_NOT_ACTIVE | The API User account is not active. |
IP_NOT_ALLOWED | Caller IP is not in the API User whitelist. |
RATE_LIMITED | Too many requests in the current rate-limit window. |
API_USER_BLOCKED | A general penalty clears on the next API request when the 7-day error count falls to or below the threshold. A cross-account security block requires administrator unblocking. |
DUPLICATE_ORDER_NO | orderNo has already been used by the same API User. |
ORDER_NOT_FOUND | The order does not exist or is not owned by the current API User. |
ORDER_ACCESS_DENIED | The order exists but does not belong to the current API User. |
SUBSCRIPTION_NOT_FOUND | The Auto Energy subscription does not exist or is not owned by the current API User. |
INVALID_RECEIVER_ADDRESS | receiverAddress is empty or not a valid TRON Base58Check address. |
RECEIVER_NOT_ACTIVATED | receiverAddress is not activated and cannot receive delegated energy. |
INVALID_PRICE_CONFIG | Server-side price configuration error. Contact the administrator. |
INVALID_ENERGY_TYPE | energyType must be activated or noActivated. |
INVALID_TIMES | times must be an integer from 1 to 20. |
INVALID_ORDER_DURATION | The current brand does not support this durationHours. |
INSUFFICIENT_BALANCE | API User available balance is insufficient. |
INSUFFICIENT_PLATFORM_ENERGY_CAPACITY | The platform cannot satisfy this resource request right now. Retry later or contact the administrator. |
TRX_NEEDED_UNAVAILABLE | The server cannot compute the TRX needed for delegation right now. Retry later. |
TIMEOUT | The order timed out before delegation completed. This is a service-side processing result. |
INTERNAL_ERROR | Unexpected server error. If the request admission check is unavailable, the API returns HTTP 500 without counting a user error; retry later. |
LLM Contract Summary
The JSON below is a compact contract summary for LLM / automation integrations. Use OpenAPI JSON for the full machine-readable specification.
{
"apiVersion": "v1",
"apiRuntimeVersionUrl": "https://api.trxforgas.com/v1",
"baseUrl": "Read from API User in the WebApp or Telegram Bot. Do not prepend the legacy /api prefix.",
"auth": "x-api-key header plus API User IP whitelist",
"limits": "Read endpoints default to 30 requests per 10 seconds; write endpoints default to 10 requests per 10 seconds, counted by API Key + endpoint path. General penalties return API_USER_BLOCKED above the configured 7-day error threshold and clear on the next API request once the count is at or below it. Three cross-account access violations within 10 minutes trigger a security block requiring administrator unblocking. Service-side or platform-side errors do not count toward blocking.",
"callback": "Configure noticeUrl for deposit and ordinary-order status callbacks. Managed Auto Energy orders are excluded; Auto Energy uses dedicated events.",
"pricing": "Use GET /v1/auto-energy/subscription-quote for initial, refill-tier, and independent overnight fees; use maxInitialFeeSun and maxOvernightFeeSun as create-time caps.",
"autoEnergy": "Manages toward a 131000-Energy target with ±0.3% on-chain conversion tolerance; 64805-130999 is billed at the 65000 tier, below 64805 at the 131000 tier, then recalculated toward the target; each idle 24h only incurs the independent overnight fee.",
"paths": [
{
"method": "GET",
"path": "/v1",
"auth": false,
"purpose": "deployed version"
},
{
"method": "GET",
"path": "/v1/myInfo",
"auth": true,
"purpose": "API User account and deposit address"
},
{
"method": "GET",
"path": "/v1/swap/info",
"auth": true,
"purpose": "TRX/USDT reference rate, quote time, limits, fees, and swap address"
},
{
"method": "POST",
"path": "/v1/quote/precount",
"auth": true,
"purpose": "current quote and receiver activation check"
},
{
"method": "POST",
"path": "/v1/energy-rental/orders",
"auth": true,
"purpose": "create energy rental order"
},
{
"method": "GET",
"path": "/v1/orders/{id}",
"auth": true,
"purpose": "query by platform order id"
},
{
"method": "GET",
"path": "/v1/orders/getByOrderNo",
"auth": true,
"purpose": "query by external orderNo"
},
{
"method": "GET",
"path": "/v1/tasks/{taskId}",
"auth": true,
"purpose": "look up auto-activation task status"
},
{
"method": "GET",
"path": "/v1/auto-energy/subscription-quote",
"auth": true,
"purpose": "quote Auto Energy subscription fee"
},
{
"method": "POST",
"path": "/v1/auto-energy/subscriptions",
"auth": true,
"purpose": "create Auto Energy subscription"
},
{
"method": "GET",
"path": "/v1/auto-energy/subscriptions",
"auth": true,
"purpose": "list Auto Energy subscriptions"
},
{
"method": "GET/POST",
"path": "/v1/auto-energy/subscriptions/{id}",
"auth": true,
"purpose": "query or stop subscription"
}
],
"moneyUnit": "SUN. 1 TRX = 1,000,000 SUN.",
"status": {
"0": "pending",
"1": "delegated",
"2": "completed",
"3": "delegating",
"-1": "failed",
"-2": "refunded"
}
}