> For the complete documentation index, see [llms.txt](https://tronex.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tronex.gitbook.io/docs/api-documentation/api-v1/energy.md).

# Energy

## Get energy price

> Request for preliminary calculation of energy purchase cost. The user provides an authentication token, as well as the parameters: energy usage period \`days\` and energy volume \`volume\`. A preliminary cost estimate is returned in the response.\
> \
> \*\*Limits:\*\*\
> \- Energy duration period (Possible values: 1h, 1d, 3d, 7d)\
> \- Energy volume \`volume\` must be at least 65K and no more than 4M.\
> \- Energy cannot be transferred to \*\*inactive wallets\*\*.\
> \
> \*\*Usage example:\*\*\
> \`\`\`http\
> &#x20; POST <https://api.tronex.energy/api/v1/precountOrder\\>
> &#x20; Content-Type: application/json\
> &#x20; X-API-KEY: authentication\_token\
> \
> &#x20; {\
> &#x20;   "days": "1d",\
> &#x20;   "volume": 65000\
> &#x20; }\
> \`\`\`<br>

````json
{"openapi":"3.0.3","info":{"title":"Tronex API","version":"1.0.0"},"servers":[{"url":"https://api.tronex.energy","description":"API Server"}],"security":[{"apiKey":[]}],"components":{"securitySchemes":{"apiKey":{"type":"apiKey","in":"header","name":"X-API-KEY","description":"API key for authentication"}}},"paths":{"/api/v1/precountOrder":{"post":{"summary":"Get energy price","tags":["Energy"],"description":"Request for preliminary calculation of energy purchase cost. The user provides an authentication token, as well as the parameters: energy usage period `days` and energy volume `volume`. A preliminary cost estimate is returned in the response.\n\n**Limits:**\n- Energy duration period (Possible values: 1h, 1d, 3d, 7d)\n- Energy volume `volume` must be at least 65K and no more than 4M.\n- Energy cannot be transferred to **inactive wallets**.\n\n**Usage example:**\n```http\n  POST https://api.tronex.energy/api/v1/precountOrder\n  Content-Type: application/json\n  X-API-KEY: authentication_token\n\n  {\n    \"days\": \"1d\",\n    \"volume\": 65000\n  }\n```\n","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"days":{"type":"string","enum":["1h","1d","3d","7d"]},"volume":{"type":"number","minimum":65000,"maximum":4000000}},"required":["days","volume"]}}},"required":true},"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"duration":{"type":"string","enum":["1h","1d","3d","7d"],"description":"Energy rental period"},"volume":{"type":"number"},"price":{"type":"number"},"summa":{"type":"number"}},"required":["duration","volume","price","summa"],"additionalProperties":false,"description":"Preliminary cost"}}}},"400":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"statusCode":{"type":"number","enum":[400]},"code":{"default":"BAD_REQUEST","type":"string"},"error":{"default":"Bad Request","type":"string"},"message":{"default":"Bad Request","type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"path":{"type":"string"},"message":{"type":"string"}},"required":["path","message"],"additionalProperties":false}}},"required":["statusCode","code","error","message"],"additionalProperties":false,"description":"Bad request error"}}}},"401":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"statusCode":{"type":"number","enum":[401]},"code":{"default":"UNAUTHORIZED","type":"string"},"error":{"default":"Unauthorized","type":"string"},"message":{"default":"Invalid authorization token","type":"string"}},"required":["statusCode","code","error","message"],"additionalProperties":false,"description":"Unauthorized error"}}}}}}}}}
````

## Buy energy

> Request to purchase energy with parameters: Energy duration period, Energy volume, and target address. The user provides an authentication token in the request header and sends a JSON payload. The response returns the status of the operation.\
> \
> \*\*Limits:\*\*\
> \- Energy duration period (Possible values: 1h, 1d, 3d, 7d)\
> \- Energy volume \`volume\` must be at least 65K and no more than 4M.\
> \- Energy cannot be transferred to \*\*inactive wallets\*\*.\
> \
> \*\*Usage example:\*\*\
> \
> &#x20; \`\`\`http\
> &#x20; POST <https://api.tronex.energy/api/v1/buyenergy\\>
> &#x20; Content-Type: application/json\
> &#x20; X-API-KEY: authentication\_token\
> \
> {\
> &#x20; "days": "1d",\
> &#x20; "volume": 65000,\
> &#x20; "target": "TVVX6svz6vXGVACeH9jNMk5M3dH5SvcT71"\
> } \`\`\`<br>

````json
{"openapi":"3.0.3","info":{"title":"Tronex API","version":"1.0.0"},"servers":[{"url":"https://api.tronex.energy","description":"API Server"}],"security":[{"apiKey":[]}],"components":{"securitySchemes":{"apiKey":{"type":"apiKey","in":"header","name":"X-API-KEY","description":"API key for authentication"}}},"paths":{"/api/v1/buyenergy":{"post":{"summary":"Buy energy","tags":["Energy"],"description":"Request to purchase energy with parameters: Energy duration period, Energy volume, and target address. The user provides an authentication token in the request header and sends a JSON payload. The response returns the status of the operation.\n\n**Limits:**\n- Energy duration period (Possible values: 1h, 1d, 3d, 7d)\n- Energy volume `volume` must be at least 65K and no more than 4M.\n- Energy cannot be transferred to **inactive wallets**.\n\n**Usage example:**\n\n  ```http\n  POST https://api.tronex.energy/api/v1/buyenergy\n  Content-Type: application/json\n  X-API-KEY: authentication_token\n\n{\n  \"days\": \"1d\",\n  \"volume\": 65000,\n  \"target\": \"TVVX6svz6vXGVACeH9jNMk5M3dH5SvcT71\"\n} ```\n","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"days":{"default":"1h","description":"Energy rental period","type":"string","enum":["1h","1d","3d","7d"]},"volume":{"default":65000,"description":"Amount of energy to buy","type":"number","minimum":65000,"maximum":4000000},"target":{"type":"string","description":"Wallet address to receive energy"}},"required":["target"]}}},"required":true},"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"days":{"type":"string","enum":["1h","1d","3d","7d"]},"volume":{"type":"number"},"price":{"type":"number"},"summa":{"type":"number"},"target":{"type":"string"},"order_id":{"type":"number"},"status":{"type":"string","enum":["Filled","Pending","Cancelled"]},"txid":{"nullable":true,"type":"string"}},"required":["days","volume","price","summa","target","order_id","status","txid"],"additionalProperties":false,"description":"Order created successfully"}}}},"400":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"statusCode":{"type":"number","enum":[400]},"code":{"default":"BAD_REQUEST","type":"string"},"error":{"default":"Bad Request","type":"string"},"message":{"default":"Bad Request","type":"string"},"details":{"type":"array","items":{"type":"object","properties":{"path":{"type":"string"},"message":{"type":"string"}},"required":["path","message"],"additionalProperties":false}}},"required":["statusCode","code","error","message"],"additionalProperties":false,"description":"Bad request error"}}}},"401":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"statusCode":{"type":"number","enum":[401]},"code":{"default":"UNAUTHORIZED","type":"string"},"error":{"default":"Unauthorized","type":"string"},"message":{"default":"Invalid authorization token","type":"string"}},"required":["statusCode","code","error","message"],"additionalProperties":false,"description":"Unauthorized error"}}}},"402":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"statusCode":{"type":"number","enum":[402]},"code":{"default":"INSUFFICIENT_FUNDS","type":"string"},"error":{"default":"Payment Required","type":"string"},"message":{"default":"Insufficient funds to create an order","type":"string"}},"required":["statusCode","code","error","message"],"additionalProperties":false,"description":"Insufficient funds error"}}}}}}}}}
````

## Get amount of energy needed to send transaction

> The method is used to get the amount of energy needed to send a transaction to the TRON network. The user must provide a valid authentication token in header and an array of TRON addresses in the request body.

```json
{"openapi":"3.0.3","info":{"title":"Tronex API","version":"1.0.0"},"servers":[{"url":"https://api.tronex.energy","description":"API Server"}],"security":[{"apiKey":[]}],"components":{"securitySchemes":{"apiKey":{"type":"apiKey","in":"header","name":"X-API-KEY","description":"API key for authentication"}}},"paths":{"/api/v1/cost":{"post":{"summary":"Get amount of energy needed to send transaction","tags":["Energy"],"description":"The method is used to get the amount of energy needed to send a transaction to the TRON network. The user must provide a valid authentication token in header and an array of TRON addresses in the request body.","requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"targets":{"type":"array","items":{"type":"string"}}},"required":["targets"],"description":"Array of TRON addresses to check energy cost"}}},"description":"Array of TRON addresses to check energy cost","required":true},"responses":{"200":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"type":"object","properties":{"address":{"type":"string"},"need_energy":{"type":"number"}},"required":["address","need_energy"],"additionalProperties":false}}},"required":["data"],"additionalProperties":false,"description":"Energy cost calculated successfully"}}}},"401":{"description":"Default Response","content":{"application/json":{"schema":{"type":"object","properties":{"statusCode":{"type":"number","enum":[401]},"code":{"default":"UNAUTHORIZED","type":"string"},"error":{"default":"Unauthorized","type":"string"},"message":{"default":"Invalid authorization token","type":"string"}},"required":["statusCode","code","error","message"],"additionalProperties":false,"description":"Unauthorized error"}}}}}}}}}
```
