TRX For Gas

TRX For Gas API · Web2 / Web3

The V1 TRON energy rental API for API Users. This document follows ApiV1Controller and covers account lookup, quote before ordering, order creation, order lookup, and Auto Energy subscriptions. Existing customers can continue using legacy /api/*; new integrations should use /v1/*.

Web2 Auth: x-api-keyIP whitelistUnit: SUNAPI version: loading

Web2 uses API User accounts. For anonymous wallet payments, see the Web3 section.

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.

ItemDescription
Read rate limitCounted by API Key + endpoint path. Default: up to 30 requests per 10 seconds.
Write rate limitOrder creation and subscription creation are counted by API Key + endpoint path. Default: up to 10 requests per 10 seconds.
Subscription detail and closeGET /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 blockingIf 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 blockingINVALID_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 acceptanceCallback 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.
ScenariotypeDescription
Deposit crediteddepositTRX was received by the user's deposit address and credited to the account.
Order status changedorderEnergy order success, failure, or completion. Managed Auto Energy allocations are excluded from ordinary order callbacks.
Auto Energy lifecycle or billingautoEnergyStart, 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

FieldMeaning
typeCallback type. Deposit callbacks always use deposit.
idDeposit record ID. Use it for idempotency.
userIdSystem user ID of the API User.
addressAPI User deposit address in Base58Check format.
fromAddressOn-chain sender address in Base58Check format.
amountCredited amount in SUN.
txHashDeposit transaction hash.
createdAtDeposit 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
}
FieldMeaning
typeCallback type. Order status callbacks always use order.
idSystem order ID. Use it for idempotency.
orderNoExternal order number submitted when creating the order. It may be null when omitted.
orderTimeRental duration in seconds.
orderTypeOrder type.
paidAmountActual paid or frozen amount in SUN. Failed-order refunds use this field.
receiverAddressTRON Base58Check address receiving the resource.
resourceAmountDelegated energy amount.
resourceTypeResource type. Energy orders currently use 1.
status0=pending, 1=delegated, 2=completed, 3=delegating, -1=failed, -2=refunded.
callbackStatusSUCCESS=the purchase is successful; FAILED=the order failed; PENDING=pending; UNKNOWN=other processing state.
failReasonPublic failure reason. It is null on success. User-actionable reasons are returned as-is; service-side reasons are returned as 服务端错误.
activationAddress activation information attached to this order. null for normal orders or orders without address activation.
activation.taskIdAddress activation ID, used for idempotency and activation progress lookup.
activation.statusOverall address activation status.
activation.failReasonActivation failure reason. null while processing or on success.
activation.currentStepCurrent activation step.
activation.activationStatusOn-chain address activation transaction status.
activation.feeSunAddress activation fee in SUN.
activation.paidAmountSunActual activation amount charged in SUN.
activation.paidAmountTrxActual activation amount charged in TRX.
activation.txHashAddress activation transaction hash. null when not submitted or unavailable.
hashFirst on-chain transaction hash for this resource delivery, or null when unavailable.
hashesAll on-chain transaction hashes for this resource delivery. Empty when no transaction hash is available.
timeStampOrder creation timestamp in milliseconds.
timesTransfer count.
totalFeeOrder amount in SUN. For direct-transfer overpayments, this is the matched quote amount; see paidAmount for the actual paid amount.
updatedAtLast 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

GET/v1
No auth

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

FieldMeaning
versionCurrent 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

FieldMeaning
quote.availableWhether a displayable reference rate and enabled swap address are currently available.
quote.quoteTimeTime when this reference quote was fetched, in ISO-8601 UTC format. Display this time together with the rate when showing the quote.
quote.quoteAtSame value as quoteTime, kept for existing display code.
quote.nextRefreshAtNext scheduled refresh time for the reference rate.
quote.refreshIntervalSecondsRecommended refresh interval. Currently 60 seconds.
quote.oneUsdtToTrxReference TRX amount normalized to 1 USDT.
quote.usdtToTrxInputActual USDT input used for the USDT → TRX reference quote. The minimum input is used when it exceeds 1 USDT.
quote.usdtToTrxReferenceOutputReference TRX output corresponding to usdtToTrxInput.
quote.hundredTrxToUsdtReference USDT amount for 100 TRX.
quote.trxToUsdtTRX to USDT enable flag, input/output tokens, single-transfer input limits, and fee rules.
quote.usdtToTrxUSDT to TRX enable flag, input/output tokens, single-transfer input limits, and fee rules.
quote.*.feeBpsFee rate in basis points; 100 basis points equals 1%.
quote.*.feePercentFormatted fee percentage value without the percent sign.
quote.*.feeDeductionModeBEFORE_SWAP deducts the fee from the input token before swapping; AFTER_SWAP deducts it from the output token after swapping.
quote.*.feeTokenToken in which the fee is charged.
quote.*.minFeeMinimum fee for the direction, denominated in feeToken.
quote.addressFirst enabled on-chain swap address, convenient for display or copy.
quote.addressesAll enabled swap addresses.
GET/v1/myInfo
Account

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
}
FieldMeaning
idSystem user ID of the API User.
nameAPI User name.
avaliableBalanceAvailable balance in SUN.
addressForDepositDedicated API User deposit address in Base58Check format.
apiKeyMaskedMasked API Key, used only to identify the current key.
noticeUrlConfigured HTTP callback URL. Empty string when not configured.
createdAtAPI User creation time.
updatedAtLast 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.

FieldRequiredTypeDescription
timesyesintPurchase quantity. Must be a positive integer within the configured per-order limit (20 by default).
receiverAddressyesstringTRON Base58Check address that receives the delegated energy.
energyTypenostringactivated 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.
durationHoursnointWhole-hour rental duration. Defaults to 1. Supported values: 1, 4, 8, 24.
autoActivatenobooleanDefaults 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
}
FieldMeaning
validWhether the quote is valid. If false, check reason.
reasonQuote failure reason. null when the quote succeeds.
receiverAddressRequested TRON Base58Check address receiving the resource.
addressValidWhether the receiver address format is valid.
addressActivatedWhether the receiver address is currently activated.
energyTypeEnergy type used for the quote: activated or noActivated.
timesTransfer count used for this quote.
durationSecondsRental duration in seconds.
durationHoursRental duration in hours. Supported values: 1, 4, 8, 24.
energyAmountEstimated delegated energy amount.
finalFeeSunEstimated energy order fee in SUN. Does not include activation fee.
finalFeeTrxEstimated energy order fee in TRX. Does not include activation fee.
autoActivateWhether this request asks the server to auto-activate an inactive address.
needActivationWhether this request needs address activation first.
activationFeeSunEstimated activation fee in SUN. Greater than 0 only when needActivation=true.
activationFeeTrxEstimated activation fee in TRX.
estimatedTotalFeeSunEstimated total fee in SUN: energy fee plus possible activation fee. This does not lock the price.
estimatedTotalFeeTrxEstimated 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.

FieldRequiredTypeDescription
timesyesintPurchase quantity. Must be a positive integer within the configured per-order limit (20 by default).
receiverAddressyesstringTRON Base58Check address that receives the delegated energy.
orderNoyesstringExternal order number. Must be unique for the same API User.
energyTypeyesstringactivated 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.
durationHoursnointWhole-hour rental duration. Defaults to 1.
autoActivatenobooleanDefaults 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.

FieldMeaning
idSystem order ID. null before the real energy order is created after activation.
orderNoExternal order number submitted when creating the order. Unique under the same API User.
orderTimeRental duration in seconds.
orderTypeOrder type. Energy rental orders currently use 0; null before the real order is created.
paidAmountActual paid or frozen amount in SUN. null before the real order is created.
receiverAddressTRON Base58Check address receiving the resource.
resourceAmountDelegated energy amount. null before the real order is created.
resourceTypeResource type. Energy orders currently use 1.
status0=pending, 1=delegated, 2=completed, 3=delegating, -1=failed, -2=refunded. null before the real order is created.
failReasonFailure reason. null when successful or still processing.
timeStampOrder creation timestamp in milliseconds. null before the real order is created.
timesTransfer count.
totalFeeOrder 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.
updatedAtLast order update time. null before the real order is created.
activationAddress activation information. null for normal orders.
activation.taskIdAddress activation ID for progress lookup.
activation.statusOverall address activation status.
activation.failReasonActivation failure reason. null while processing or on success.
activation.currentStepCurrent activation step.
activation.activationStatusOn-chain address activation transaction status.
activation.feeSunAddress activation fee in SUN.
activation.feeTrxAddress activation fee in TRX.
activation.paidAmountSunCharged activation amount in SUN.
activation.paidAmountTrxCharged activation amount in TRX.
activation.txHashAddress activation transaction hash. null when not submitted or unavailable.
activation.energyOrderIdEnergy order ID created after activation. null before it is created.
activation.autoEnergySubscriptionIdAuto 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

FieldMeaning
idSystem order ID.
orderNoExternal order number submitted when creating the order. Unique under the same API User.
orderTimeRental duration in seconds.
orderTypeOrder type. Energy rental orders currently use 0.
paidAmountActual paid or frozen amount in SUN. Failed-order refunds use this field.
receiverAddressTRON Base58Check address receiving the resource.
resourceAmountDelegated energy amount.
resourceTypeResource type. Energy orders currently use 1.
status0=pending, 1=delegated, 2=completed, 3=delegating, -1=failed, -2=refunded.
failReasonPublic failure reason. null when the order succeeded or is still processing.
timeStampOrder creation timestamp in milliseconds.
timesTransfer count.
totalFeeOrder amount in SUN. For direct-transfer overpayments, this is the matched quote amount; see paidAmount for the actual paid amount.
updatedAtLast order update time.
activationAddress activation information attached to this order. null for regular orders or when no activation was created.
activation.taskIdAddress activation ID. Use it to query activation progress.
activation.statusOverall address activation status.
activation.failReasonActivation failure reason. null while processing or on success.
activation.currentStepCurrent activation step.
activation.activationStatusOn-chain activation transaction status.
activation.feeSunActivation fee in SUN.
activation.feeTrxActivation fee in TRX.
activation.paidAmountSunCharged activation amount in SUN.
activation.paidAmountTrxCharged activation amount in TRX.
activation.txHashActivation transaction hash. null before submission or when unavailable.
activation.energyOrderIdEnergy order ID created after activation. null before it is created or when not applicable.
activation.autoEnergySubscriptionIdAuto 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

FieldMeaning
idSystem order ID.
orderNoExternal order number submitted when creating the order. Unique under the same API User.
orderTimeRental duration in seconds.
orderTypeOrder type. Energy rental orders currently use 0.
paidAmountActual paid or frozen amount in SUN. Failed-order refunds use this field.
receiverAddressTRON Base58Check address receiving the resource.
resourceAmountDelegated energy amount.
resourceTypeResource type. Energy orders currently use 1.
status0=pending, 1=delegated, 2=completed, 3=delegating, -1=failed, -2=refunded.
failReasonPublic failure reason. null when the order succeeded or is still processing.
timeStampOrder creation timestamp in milliseconds.
timesTransfer count.
totalFeeOrder amount in SUN. For direct-transfer overpayments, this is the matched quote amount; see paidAmount for the actual paid amount.
updatedAtLast order update time.
activationAddress activation information attached to this order. null for regular orders or when no activation was created.
activation.taskIdAddress activation ID. Use it to query activation progress.
activation.statusOverall address activation status.
activation.failReasonActivation failure reason. null while processing or on success.
activation.currentStepCurrent activation step.
activation.activationStatusOn-chain activation transaction status.
activation.feeSunActivation fee in SUN.
activation.feeTrxActivation fee in TRX.
activation.paidAmountSunCharged activation amount in SUN.
activation.paidAmountTrxCharged activation amount in TRX.
activation.txHashActivation transaction hash. null before submission or when unavailable.
activation.energyOrderIdEnergy order ID created after activation. null before it is created or when not applicable.
activation.autoEnergySubscriptionIdAuto 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.
FieldRequiredDescription
receiverAddressyesTRON Base58Check receiver.
maxInitialFeeSunnoCap for the initial 131000-Energy fee.
maxOvernightFeeSunnoAuthorization cap for each overnight charge.
autoActivatenoActivate an inactive receiver first.
clientTaskNonoActivation-task idempotency key.
maxActivationFeeSunnoActivation-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.

EndpointDescription
GET /v1/auto-energy/subscriptions?page=1&pageSize=10List current-user subscriptions.
GET /v1/auto-energy/subscriptions/{id}Get one subscription.
POST /v1/auto-energy/subscriptions/{id}/closeMove to CLOSING and reclaim asynchronously; the terminal status is CLOSED.
GET /v1/auto-energy/subscriptions/{id}/billing-records?page=1&pageSize=10Recommended public-safe list of INITIAL, USAGE_TOPUP, and OVERNIGHT billing records.
GET /v1/auto-energy/subscriptions/{id}/charges?page=1&pageSize=10Deprecated 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.

typeRequired fieldsOptional fields
energypayerAddress, packageIdreceiverAddress
swappayerAddress, fromAsset, toAsset, amountreceiverAddress (must equal payer)
bridgepayerAddress, 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.

statusMeaning
not_foundNot indexed yet or no matching direct-transfer payment. Do not pay again.
waiting_paymentBridge order awaiting payment.
processingPayment detected, delivery still in progress.
completedExisting business records indicate delivery completed.
settledAll matched events finished, with mixed delivery/refund results; inspect payments[].
expiredBridge payment window closed.
refunding / refundedExisting refund in progress / recorded as completed.
attention_requiredNeeds 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 CodesMeaning
INVALID_REQUESTRequest body, path parameter, query parameter, or JSON type is invalid.
INVALID_API_KEYMissing or invalid x-api-key.
NOT_API_USERThe API Key does not belong to an API User account.
USER_NOT_ACTIVEThe API User account is not active.
IP_NOT_ALLOWEDCaller IP is not in the API User whitelist.
RATE_LIMITEDToo many requests in the current rate-limit window.
API_USER_BLOCKEDA 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_NOorderNo has already been used by the same API User.
ORDER_NOT_FOUNDThe order does not exist or is not owned by the current API User.
ORDER_ACCESS_DENIEDThe order exists but does not belong to the current API User.
SUBSCRIPTION_NOT_FOUNDThe Auto Energy subscription does not exist or is not owned by the current API User.
INVALID_RECEIVER_ADDRESSreceiverAddress is empty or not a valid TRON Base58Check address.
RECEIVER_NOT_ACTIVATEDreceiverAddress is not activated and cannot receive delegated energy.
INVALID_PRICE_CONFIGServer-side price configuration error. Contact the administrator.
INVALID_ENERGY_TYPEenergyType must be activated or noActivated.
INVALID_TIMEStimes must be an integer from 1 to 20.
INVALID_ORDER_DURATIONThe current brand does not support this durationHours.
INSUFFICIENT_BALANCEAPI User available balance is insufficient.
INSUFFICIENT_PLATFORM_ENERGY_CAPACITYThe platform cannot satisfy this resource request right now. Retry later or contact the administrator.
TRX_NEEDED_UNAVAILABLEThe server cannot compute the TRX needed for delegation right now. Retry later.
TIMEOUTThe order timed out before delegation completed. This is a service-side processing result.
INTERNAL_ERRORUnexpected 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"
  }
}