Maintainers
Pricing
Enterprise
More
More
Documentation
Try Live
Rankings
Install
Blog
Docs7
Ask
New
Add Docs
Tronzap
https://docs.tronzap.com/
Admin
Documentation repository created by Site2MD.
Tokens:
34,451
Snippets:
196
Trust Score:
7.5
Update:
4 months ago
Context
Chat
Benchmark
Latest
Show doc for...
Code
Info
Show Results
Tokens:
Raw
Copy
Link
Tokens:
Raw
Copy
Link
### Start Subscription with Python Source: https://docs.tronzap.com/api/subscription-start.html This Python example demonstrates how to start an Energy subscription. It includes setting up credentials, preparing the JSON payload, calculating the SHA256 signature, and sending the POST request using the requests library. ```python import hashlib import json import requests api_token = 'your_api_token' api_secret = 'your_api_secret' request_body = json.dumps({ 'subscription_id': 'unlimited_energy', 'external_id': 'my-subscription-123', 'params': { 'address': 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t', 'duration': 30, 'transactions_limit': 0, 'activate_address': True } }) # Calculate signature signature = hashlib.sha256((request_body + api_secret).encode()).hexdigest() # Execute API request headers = { 'Authorization': f'Bearer {api_token}', 'X-Signature': signature, 'Content-Type': 'application/json' } response = requests.post( 'https://api.tronzap.com/v1/subscription/start', headers=headers, data=request_body ) print(response.json()) ``` -------------------------------- ### Start Subscription with Node.js Source: https://docs.tronzap.com/api/subscription-start.html Initiate a new Energy subscription using Node.js. This example demonstrates setting up API credentials, creating the request payload, computing the signature, and sending the request with axios. ```javascript const crypto = require('crypto'); const axios = require('axios'); const apiToken = 'your_api_token'; const apiSecret = 'your_api_secret'; const requestBody = JSON.stringify({ subscription_id: 'unlimited_energy', external_id: 'my-subscription-123', params: { address: 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t', duration: 30, transactions_limit: 0, activate_address: true } }); // Calculate signature const signature = crypto .createHash('sha256') .update(requestBody + apiSecret) .digest('hex'); // Execute API request axios({ method: 'post', url: 'https://api.tronzap.com/v1/subscription/start', headers: { 'Authorization': `Bearer ${apiToken}`, 'X-Signature': signature, 'Content-Type': 'application/json' }, data: requestBody }) .then(response => console.log(response.data)) .catch(error => console.error(error)); ``` -------------------------------- ### Install Node.js SDK Source: https://docs.tronzap.com/sdk.html Install the TronZap SDK for Node.js, Bun, or Deno using npm, yarn, or pnpm. ```bash npm install tronzap-sdk # or yarn add tronzap-sdk # or pnpm add tronzap-sdk ``` -------------------------------- ### Install PHP SDK Source: https://docs.tronzap.com/sdk.html Install the TronZap PHP SDK using Composer. ```bash composer require tron-energy-market/tronzap-sdk-php ``` -------------------------------- ### Install Python SDK Source: https://docs.tronzap.com/sdk.html Install the TronZap Python SDK using pip. ```bash pip install tronzap-sdk ``` -------------------------------- ### Example API Response (Activated Address) Source: https://docs.tronzap.com/api/calculate.html This is an example of a successful API response when the TRON address is already activated. It details the cost breakdown for the requested resource purchase. ```json { "code": 0, "request_id": "bbf74bcd-fb36-4df8-adc8-25f2bacd087b", "result": { "address": "TRX_ADDRESS", "type": "energy", "amount": 50000, "energy": 50000, "duration": 1, "price": 1.67, "activation_fee": 0, "total": 1.67 } } ``` -------------------------------- ### Start Subscription Source: https://docs.tronzap.com/api/subscription-start.html Initiates a new subscription for a given TRON address. This endpoint is used to activate services like energy or bandwidth. ```APIDOC ## POST /v1/subscription/start ### Description Starts a new subscription for a specified TRON address and subscription type. This is a core endpoint for users to acquire services. ### Method POST ### Endpoint /v1/subscription/start ### Parameters #### Request Body - **subscription_id** (string) - Required - The ID of the subscription type to purchase (e.g., "unlimited_energy"). - **address** (string) - Required - The TRON address for which to purchase the subscription. - **duration** (integer) - Optional - The duration of the subscription in days. If not specified, the subscription might be perpetual or have a default duration based on the `subscription_id`. - **transactions_limit** (integer) - Optional - A limit on the number of transactions allowed within the subscription period. A value of 0 typically means unlimited. - **external_id** (string) - Optional - An identifier for the subscription from an external system, useful for tracking. - **params** (object) - Optional - Additional parameters specific to the subscription type. ### Request Example { "subscription_id": "unlimited_energy", "address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", "duration": 1, "transactions_limit": 0, "external_id": "your_external_ref_123", "params": {} } ### Response #### Success Response (200) - **code** (integer) - Response code (0 indicates success). - **request_id** (string) - Unique identifier for the request. - **result** (object) - Contains the details of the created subscription. - **id** (string) - The unique ID generated for this specific subscription instance. - **subscription_id** (string) - The type of subscription purchased. - **created_at** (string) - The timestamp when the subscription was created. - **expire_at** (string) - The timestamp when the subscription expires. This will be null if no duration was specified. - **address** (string) - The TRON address associated with the subscription. - **status** (string) - The current status of the subscription (e.g., "active"). - **external_id** (string) - The external ID provided in the request, or null if not provided. - **params** (object) - The original parameters used to create the subscription. #### Response Example { "code": 0, "request_id": "bbf74bcd-fb36-4df8-adc8-25f2bacd087b", "result": { "id": "01k33rz57drtqgqcedyn9tvk04", "subscription_id": "unlimited_energy", "created_at": "2025-08-20T12:58:52+00:00", "expire_at": "2025-08-21T12:58:52+00:00", "address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", "status": "active", "external_id": null, "params": { "address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", "activate_address": false, "duration": 1, "transactions_limit": 0 } } } ### Possible Errors - **1 (auth)**: Authentication error (invalid token or signature). - **2 (invalid_service_or_params)**: Invalid service or parameters provided. - **5 (wallet_not_found)**: The specified TRON wallet address was not found. - **6 (insufficient_funds)**: The account has insufficient funds to complete the purchase. - **10 (invalid_tron_address)**: The provided TRON address is invalid, or an active subscription already exists for this address. - **12 (invalid_duration)**: The specified duration for the subscription is invalid. - **24 (address_not_activated)**: The TRON address must be activated before a subscription can be purchased. - **35 (service_unavailable)**: The requested service is currently unavailable. - **500 (internal_server_error)**: An unexpected error occurred on the server. ``` -------------------------------- ### Direct Recharge Info Response Example Source: https://docs.tronzap.com/api/direct-recharge-info.html This is an example of a successful response from the direct recharge info endpoint, showing the recharge address and available rates. ```json { "code": 0, "request_id": "bbf74bcd-fb36-4df8-adc8-25f2bacd087b", "result": { "address": "TRONZAP_PUBLIC_TRX_ADDRESS", "rates": [ { "duration": 1, "min_energy": 50000, "max_energy": 131000, "price": 0.052300000, "price_32k": 1.67, "price_65k": 3.4, "price_131k": 6.85 } ] } } ``` -------------------------------- ### Example API Response (Address Not Activated) Source: https://docs.tronzap.com/api/calculate.html This example shows an API response when the TRON address requires activation. The 'activation_fee' field indicates the additional cost, and 'total' reflects the final price including this fee. ```json { "code": 0, "request_id": "bbf74bcd-fb36-4df8-adc8-25f2bacd087b", "result": { "address": "TRX_ADDRESS", "type": "energy", "amount": 50000, "energy": 50000, "duration": 1, "price": 3.67, "activation_fee": 1.4, "total": 5.07 } } ``` -------------------------------- ### Example API Response for Transaction Creation Source: https://docs.tronzap.com/api/transaction-create.html This is an example of a successful response when creating a transaction. It includes details like the transaction ID, status, and creation timestamp. ```json { "code": 0, "request_id": "bbf74bcd-fb36-4df8-adc8-25f2bacd087b", "result": { "id": "transaction_id", "external_id": "my-external-id-123", "service": "energy", "params": { "address": "TRX_ADDRESS", "energy_amount": 65000, "duration": 1, "activate_address": false }, "status": "success", "amount": 8.25, "created_at": "2024-03-22T12:00:00Z", "hash": "transaction_hash" } } ``` -------------------------------- ### Create Energy Purchase Transaction (Python) Source: https://docs.tronzap.com/api/transaction-create.html This Python example shows how to initiate an energy purchase transaction, including generating the necessary SHA256 signature and sending the request with the requests library. ```python import hashlib import json import requests api_token = 'your_api_token' api_secret = 'your_api_secret' request_body = json.dumps({ 'external_id': 'my-external-id-123', 'service': 'energy', 'params': { 'address': 'TRX_ADDRESS', 'energy_amount': 65000, 'duration': 1 } }) # Calculate signature signature = hashlib.sha256((request_body + api_secret).encode()).hexdigest() # Make API request headers = { 'Authorization': f'Bearer {api_token}', 'X-Signature': signature, 'Content-Type': 'application/json' } response = requests.post( 'https://api.tronzap.com/v1/transaction/new', headers=headers, data=request_body ) print(response.json()) ``` -------------------------------- ### Basic Usage: Python Source: https://docs.tronzap.com/sdk.html Initialize the TronZap client, get services, create an energy transaction, and check its status using the Python SDK. Handle potential TronZapError exceptions. ```python from tronzap_sdk import TronZapClient, TronZapError # Initialize the client api_token = 'your_api_token' api_secret = 'your_api_secret' client = TronZapClient(api_token, api_secret) try: # Get available services services = client.get_services() # Create an energy transaction transaction = client.create_energy_transaction( address='TRX_ADDRESS', # TRON wallet address energy_amount=65000, # Energy amount duration=1, # Duration (hours) external_id='my-tx-id', # External ID (optional) activate_address=False # Don't activate address (optional) ) # Check transaction status status = client.check_transaction(transaction['result']['transaction_id']) except TronZapError as e: print(f"Error: {e.message} (Code: {e.code})") ``` -------------------------------- ### Get Services Source: https://docs.tronzap.com/api/services.html This endpoint returns a list of available services and their prices. No parameters are required for this request. ```APIDOC ## POST /v1/services ### Description This endpoint returns a list of available services and their prices. ### Method POST ### Endpoint /v1/services ### Parameters No parameters are required for this request. ### Request Example ```json {} ``` ### Response #### Success Response (200) - **code** (integer) - Response code (0 = success) - **request_id** (string) - Unique request identifier - **result** (object) - Response data - **result.energy** (array) - List of available energy services - **result.energy[].duration** (integer) - Duration in hours - **result.energy[].min_amount** (integer) - Minimum energy amount - **result.energy[].max_amount** (integer) - Maximum energy amount - **result.energy[].min_energy** (integer) - Minimum energy amount (deprecated, use `min_amount`) - **result.energy[].max_energy** (integer) - Maximum energy amount (deprecated, use `max_amount`) - **result.energy[].price** (float) - Price per 1000 energy - **result.energy[].price_32k** (float) - Price for 32k energy - **result.energy[].price_65k** (float) - Price for 65k energy - **result.energy[].price_131k** (float) - Price for 131k energy - **result.activate_address** (object) - Address activation service info - **result.activate_address.price** (float) - Price for address activation #### Response Example ```json { "code": 0, "request_id": "bbf74bcd-fb36-4df8-adc8-25f2bacd087b", "result": { "energy": [ { "duration": 1, "min_amount": 50000, "max_amount": 131000, "min_energy": 50000, "max_energy": 131000, "price": 0.052300000, "price_32k": 1.67, "price_65k": 3.4, "price_131k": 6.85 }, { "duration": 1, "min_amount": 131000, "max_amount": 4000000, "min_energy": 131000, "max_energy": 4000000, "price": 0.052000000, "price_32k": 1.66, "price_65k": 3.38, "price_131k": 6.81 } ], "bandwidth": [ { "duration": 1, "min_amount": 1000, "max_amount": 50000, "price": 1 } ], "activate_address": { "price": 1.4 } } } ``` ### Errors - **1 (auth)**: Authentication error (incorrect token or signature) - **500 (internal_server_error)**: Internal server error ``` -------------------------------- ### Response Example for Available Subscriptions Source: https://docs.tronzap.com/api/subscriptions.html This JSON structure represents a successful response from the /v1/subscriptions endpoint. It details the available energy subscriptions, including their names, pricing, transaction limits, and duration. ```json { "code": 0, "request_id": "bbf74bcd-fb36-4df8-adc8-25f2bacd087b", "result": { "unlimited_energy": { "id": 1, "name": "Unlimited Energy", "activation_fee": 5.0, "initial_price": 8.0, "price": 4.0, "transactions_limit": 0, "duration_days": 0 }, "energy_pack_100": { "id": 2, "name": "Energy Pack 100", "activation_fee": 2.0, "initial_price": 10.0, "price": 5.0, "transactions_limit": 10, "duration_days": 5 } } } ``` -------------------------------- ### Fetch Available Subscriptions (Node.js) Source: https://docs.tronzap.com/api/subscriptions.html This Node.js example demonstrates how to fetch available subscriptions using axios. It calculates the SHA256 signature and includes it in the request headers. Replace placeholder credentials with your own. ```javascript const crypto = require('crypto'); const axios = require('axios'); const apiToken = 'your_api_token'; const apiSecret = 'your_api_secret'; const requestBody = JSON.stringify({}); // Calculate signature const signature = crypto .createHash('sha256') .update(requestBody + apiSecret) .digest('hex'); // Execute API request axios({ method: 'post', url: 'https://api.tronzap.com/v1/subscriptions', headers: { 'Authorization': `Bearer ${apiToken}`, 'X-Signature': signature, 'Content-Type': 'application/json' }, data: requestBody }) .then(response => console.log(response.data)) .catch(error => console.error(error)); ``` -------------------------------- ### Create Energy Purchase Transaction (Node.js) Source: https://docs.tronzap.com/api/transaction-create.html This Node.js example demonstrates how to create a transaction for energy purchase, including signature calculation and API request using axios. ```javascript const crypto = require('crypto'); const axios = require('axios'); const apiToken = 'your_api_token'; const apiSecret = 'your_api_secret'; const requestBody = JSON.stringify({ external_id: 'my-external-id-123', service: 'energy', params: { address: 'TRX_ADDRESS', energy_amount: 65000, duration: 1 } }); // Calculate signature const signature = crypto .createHash('sha256') .update(requestBody + apiSecret) .digest('hex'); // Make API request axios({ method: 'post', url: 'https://api.tronzap.com/v1/transaction/new', headers: { 'Authorization': `Bearer ${apiToken}`, 'X-Signature': signature, 'Content-Type': 'application/json' }, data: requestBody }) .then(response => console.log(response.data)) .catch(error => console.error(error)); ``` -------------------------------- ### Example API Response for Services Source: https://docs.tronzap.com/api/services.html This JSON structure represents a successful response from the /v1/services endpoint, detailing available energy and bandwidth services, as well as address activation pricing. ```json { "code": 0, "request_id": "bbf74bcd-fb36-4df8-adc8-25f2bacd087b", "result": { // Rent Energy services "energy": [ { "duration": 1, "min_amount": 50000, "max_amount": 131000, "min_energy": 50000, "max_energy": 131000, "price": 0.052300000, "price_32k": 1.67, "price_65k": 3.4, "price_131k": 6.85 }, { "duration": 1, "min_amount": 131000, "max_amount": 4000000, "min_energy": 131000, "max_energy": 4000000, "price": 0.052000000, "price_32k": 1.66, "price_65k": 3.38, "price_131k": 6.81 } ], // Rent Bandwidth services "bandwidth": [ { "duration": 1, "min_amount": 1000, "max_amount": 50000, "price": 1 } ], // Address Activation service "activate_address": { "price": 1.4 } } } ``` -------------------------------- ### Example AML Services Response Source: https://docs.tronzap.com/api/aml-checks.html This is an example of a successful response when listing AML services. It includes the response code, request ID, and a list of available services with their IDs, types, and prices. ```json { "code": 0, "request_id": "bbf74bcd-fb36-4df8-adc8-25f2bacd087b", "result": [ { "id": "01K834XCB4S535MAS78SDDD16W", "type": "address", "price": 2.5 }, { "id": "01K83530PY02QZ2D9VWG8KNK8H", "type": "hash", "price": 3.75 } ] } ``` -------------------------------- ### Basic Usage: PHP Source: https://docs.tronzap.com/sdk.html Initialize the TronZap client, get services, create an energy transaction, and check its status using the PHP SDK. Handle potential TronZap exceptions. ```php <?php use TronZap\Client; use TronZap\Exception\TronZapException; // Initialize the client $apiToken = 'your_api_token'; $apiSecret = 'your_api_secret'; $client = new Client($apiToken, $apiSecret); try { // Get available services $services = $client->getServices(); // Create an energy transaction $transaction = $client->createEnergyTransaction( 'TRX_ADDRESS', // TRON wallet address 65000, // Energy amount 1, // Duration (hours) 'my-tx-id', // External ID (optional) false // Don't activate address (optional) ); // Check transaction status $status = $client->checkTransaction($transaction['result']['transaction_id']); } catch (TronZapException $e) { echo "Error: " . $e->getMessage() . " (Code: " . $e->getCode() . ")\n"; } ``` -------------------------------- ### Subscription Start API Success Response Source: https://docs.tronzap.com/api/subscription-start.html This JSON object represents a successful response from the subscription start API. It includes details about the created subscription, such as its ID, type, creation and expiration dates, status, and the original request parameters. ```json { "code": 0, "request_id": "bbf74bcd-fb36-4df8-adc8-25f2bacd087b", "result": { "id": "01k33rz57drtqgqcedyn9tvk04", "subscription_id": "unlimited_energy", "created_at": "2025-08-20T12:58:52+00:00", "expire_at": "2025-08-21T12:58:52+00:00", "address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", "status": "active", "external_id": null, "params": { "address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", "activate_address": false, "duration": 1, "transactions_limit": 0 } } } ``` -------------------------------- ### Basic Usage: Node.js Source: https://docs.tronzap.com/sdk.html Initialize the TronZap client, get services, create an energy transaction, and check its status using the Node.js SDK. Handle TronZapError and general errors. ```javascript import { TronZapClient, TronZapError } from 'tronzap-sdk'; // Initialize the client const client = new TronZapClient({ apiToken: 'your_api_token', apiSecret: 'your_api_secret' }); async function main() { try { // Get available services const services = await client.getServices(); console.log(services); // Create energy transaction const transaction = await client.createEnergyTransaction( 'TRON_WALLET_ADDRESS', 65150, 1, 'my-tx-id', // Optional external ID true // Optional: activate address if needed ); console.log(transaction); // Check transaction status const status = await client.checkTransaction(transaction.result.transaction_id); console.log(status); } catch (error) { if (error instanceof TronZapError) { console.error(`TronZap API Error: ${error.message} (Code: ${error.code})`); } else { // Type check the error before accessing its properties if (error instanceof Error) { console.error(`General error: ${error.message}`); } else { console.error('An unknown error occurred:', error); } } } } main(); ``` -------------------------------- ### Get Available Subscriptions Source: https://docs.tronzap.com/api/subscriptions.html Returns a list of all available Energy subscriptions with their parameters and prices. This endpoint requires authentication and a signature generated from the request body and API secret. ```APIDOC ## POST /v1/subscriptions ### Description Returns a list of all available Energy subscriptions with their parameters and prices. ### Method POST ### Endpoint /v1/subscriptions ### Parameters This request does not require any parameters. ### Request Example ```json { "example": "{}" } ``` ### Response #### Success Response (200) - **code** (integer) - Response code (0 = success) - **result** (object) - Object with available subscriptions - **result.{subscription_id}.name** (string) - Subscription name - **result.{subscription_id}.activation_fee** (float) - Activation fee - **result.{subscription_id}.initial_price** (float) - Initial price - **result.{subscription_id}.price** (float) - Price per transaction - **result.{subscription_id}.transactions_limit** (integer) - Transaction limit (0 = unlimited) - **result.{subscription_id}.duration_days** (integer) - Number of days (0 = unlimited) #### Response Example ```json { "code": 0, "request_id": "bbf74bcd-fb36-4df8-adc8-25f2bacd087b", "result": { "unlimited_energy": { "id": 1, "name": "Unlimited Energy", "activation_fee": 5.0, "initial_price": 8.0, "price": 4.0, "transactions_limit": 0, "duration_days": 0 }, "energy_pack_100": { "id": 2, "name": "Energy Pack 100", "activation_fee": 2.0, "initial_price": 10.0, "price": 5.0, "transactions_limit": 10, "duration_days": 5 } } } ``` ### Possible Errors - **1 (auth)**: Authentication error (invalid token or signature) - **35 (service_unavailable)**: Service not available - **500 (internal_server_error)**: Internal server error ``` -------------------------------- ### Get Services Request (PHP) Source: https://docs.tronzap.com/api/services.html Utilize cURL in PHP to send a POST request to the /v1/services endpoint. The request must include the Authorization and X-Signature headers for authentication. ```php <?php $apiToken = 'your_api_token'; $apiSecret = 'your_api_secret'; $requestBody = json_encode([]); // Calculate signature $signature = hash('sha256', $requestBody . $apiSecret); // Make API request $ch = curl_init('https://api.tronzap.com/v1/services'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $requestBody); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer ' . $apiToken, 'X-Signature: ' . $signature, 'Content-Type: application/json' ]); $response = curl_exec($ch); curl_close($ch); echo $response; ?> ``` -------------------------------- ### Get Services Request (Bash) Source: https://docs.tronzap.com/api/services.html Make a POST request to the /v1/services endpoint using cURL. Ensure you include your API token, a calculated signature, and the correct content type. ```bash #!/bin/bash API_TOKEN="your_api_token" API_SECRET="your_api_secret" REQUEST_BODY='{}' # Calculate signature SIGNATURE=$(echo -n "${REQUEST_BODY}${API_SECRET}" | sha256sum | cut -d' ' -f1) # Make API request curl -X POST "https://api.tronzap.com/v1/services" \ -H "Authorization: Bearer ${API_TOKEN}" \ -H "X-Signature: ${SIGNATURE}" \ -H "Content-Type: application/json" \ -d "${REQUEST_BODY}" ``` -------------------------------- ### List AML Services (Python) Source: https://docs.tronzap.com/api/aml-checks.html This Python example retrieves active AML screening services. It computes a SHA256 signature and uses the requests library to perform the API call. ```python import hashlib import json import requests api_token = 'your_api_token' api_secret = 'your_api_secret' request_body = json.dumps({}) # Calculate signature signature = hashlib.sha256((request_body + api_secret).encode()).hexdigest() # Make API request headers = { 'Authorization': f'Bearer {api_token}', 'X-Signature': signature, 'Content-Type': 'application/json' } response = requests.post( 'https://api.tronzap.com/v1/aml-checks', headers=headers, data=request_body ) print(response.json()) ``` -------------------------------- ### Subscription Stop Response Example Source: https://docs.tronzap.com/api/subscription-stop.html This JSON object represents a successful response when a subscription is stopped. It includes details about the subscription's state before and after the stop operation. ```json { "code": 0, "request_id": "bbf74bcd-fb36-4df8-adc8-25f2bacd087b", "result": { "id": "01k33rz57drtqgqcedyn9tvk04", "subscription_id": "energy_monthly_unlimited", "created_at": "2024-03-22T12:00:00Z", "stopped_at": "2024-03-25T10:30:00Z", "status": "stopped", "external_id": "my-subscription-123", "params": { "address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", "duration": 30, "transactions_limit": 0, "activate_address": true } } } ``` -------------------------------- ### Subscription History Response Example Source: https://docs.tronzap.com/api/subscriptions-history.html This JSON object represents a typical response when querying for subscription history. It includes pagination details and a list of subscription items, each with its status, usage, and timing information. ```json { "code": 0, "request_id": "bbf74bcd-fb36-4df8-adc8-25f2bacd087b", "result": { "page": 1, "per_page": 10, "total": 1, "items": [ { "id": "01k33rz57drtqgqcedyn9tvk04", "status": "active", "subscription_id": "unlimited_energy", "address": "TPY1Kb8cKAZQfm95gXQQs2Mh8Uygtos21D", "transactions_limit": 0, "transactions_used": 2, "energy_used": 131000, "total_price": "8.00", "started_at": "2025-08-20T12:58:52+00:00", "renewed_at": null, "stopped_at": null, "expire_at": "2025-08-21T12:58:52+00:00", "created_at": "2025-08-20T12:58:52+00:00" }, { "id": "01k36gw6cbfx4r8jhvd1qyp697", "status": "stopped", "subscription_id": "energy_pay_per_use", "address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", "transactions_limit": 100, "transactions_used": 45, "energy_used": 2991000, "total_price": 184.0, "started_at": "2024-02-15T10:30:00Z", "renewed_at": null, "stopped_at": "2024-03-20T14:25:00Z", "expire_at": null, "created_at": "2024-02-15T10:25:00Z" } ] } } ``` -------------------------------- ### List AML Services (Node.js) Source: https://docs.tronzap.com/api/aml-checks.html This Node.js example demonstrates how to retrieve a list of active AML screening services. It calculates a SHA256 signature for authentication and uses axios to make the API call. ```javascript const crypto = require('crypto'); const axios = require('axios'); const apiToken = 'your_api_token'; const apiSecret = 'your_api_secret'; const requestBody = JSON.stringify({}); // Calculate signature const signature = crypto .createHash('sha256') .update(requestBody + apiSecret) .digest('hex'); // Make API request axios({ method: 'post', url: 'https://api.tronzap.com/v1/aml-checks', headers: { 'Authorization': `Bearer ${apiToken}`, 'X-Signature': signature, 'Content-Type': 'application/json' }, data: requestBody }) .then(response => console.log(response.data)) .catch(error => console.error(error)); ``` -------------------------------- ### Get Services Request (Node.js) Source: https://docs.tronzap.com/api/services.html Use the axios library to make a POST request to the /v1/services endpoint. The request requires an Authorization header with your Bearer token and an X-Signature header. ```javascript const crypto = require('crypto'); const axios = require('axios'); const apiToken = 'your_api_token'; const apiSecret = 'your_api_secret'; const requestBody = JSON.stringify({}); // Calculate signature const signature = crypto .createHash('sha256') .update(requestBody + apiSecret) .digest('hex'); // Make API request axios({ method: 'post', url: 'https://api.tronzap.com/v1/services', headers: { 'Authorization': `Bearer ${apiToken}`, 'X-Signature': signature, 'Content-Type': 'application/json' }, data: requestBody }) .then(response => console.log(response.data)) .catch(error => console.error(error)); ``` -------------------------------- ### Get Services Request (Python) Source: https://docs.tronzap.com/api/services.html Send a POST request using the requests library in Python to the /v1/services endpoint. The request requires a signature calculated using SHA256 and specific headers for authentication. ```python import hashlib import json import requests api_token = 'your_api_token' api_secret = 'your_api_secret' request_body = json.dumps({}) # Calculate signature signature = hashlib.sha256((request_body + api_secret).encode()).hexdigest() # Make API request headers = { 'Authorization': f'Bearer {api_token}', 'X-Signature': signature, 'Content-Type': 'application/json' } response = requests.post( 'https://api.tronzap.com/v1/services', headers=headers, data=request_body ) print(response.json()) ``` -------------------------------- ### Get Subscription History with Parameters Source: https://docs.tronzap.com/api/subscriptions-history.html Fetches a paginated list of active subscriptions using specific request parameters. Requires API token, secret, and constructs a SHA256 signature for authentication. ```bash #!/bin/bash API_TOKEN="your_api_token" API_SECRET="your_api_secret" REQUEST_BODY='{ "page": 1, "per_page": 10, "status": "active" }' # Calculate signature SIGNATURE=$(echo -n "${REQUEST_BODY}${API_SECRET}" | sha256sum | cut -d' ' -f1) # Execute API request curl -X POST "https://api.tronzap.com/v1/subscriptions/history" \ -H "Authorization: Bearer ${API_TOKEN}" \ -H "X-Signature: ${SIGNATURE}" \ -H "Content-Type: application/json" \ -d "${REQUEST_BODY}" ``` -------------------------------- ### Example Response for Estimate Energy API Source: https://docs.tronzap.com/api/estimate-energy.html This JSON object shows a typical response when estimating energy for a USDT transfer. It includes details like amount, energy, duration, price, fees, and addresses. ```json { "code": 0, "request_id": "bbf74bcd-fb36-4df8-adc8-25f2bacd087b", "result": { "amount": 64400, "energy": 64400, "duration": 1, "price": 3.66, "activation_fee": 1.4, "total": 5.06, "from_address": "TRX_FROM_ADDRESS", "to_address": "TRX_TO_ADDRESS", "contract_address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t" } } ``` -------------------------------- ### Start Subscription with Bash Source: https://docs.tronzap.com/api/subscription-start.html Use this snippet to initiate a new Energy subscription via the API using Bash. It includes setting API credentials, constructing the request body, calculating the SHA256 signature, and making the POST request. ```bash #!/bin/bash API_TOKEN="your_api_token" API_SECRET="your_api_secret" REQUEST_BODY='{ "subscription_id": "unlimited_energy", "external_id": "my-subscription-123", "params": { "address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", "duration": 30, "transactions_limit": 0, "activate_address": true } }' # Calculate signature SIGNATURE=$(echo -n "${REQUEST_BODY}${API_SECRET}" | sha256sum | cut -d' ' -f1) # Execute API request curl -X POST "https://api.tronzap.com/v1/subscription/start" \ -H "Authorization: Bearer ${API_TOKEN}" \ -H "X-Signature: ${SIGNATURE}" \ -H "Content-Type: application/json" \ -d "${REQUEST_BODY}" ``` -------------------------------- ### Start Subscription with PHP Source: https://docs.tronzap.com/api/subscription-start.html This PHP snippet shows how to create an Energy subscription. It covers API authentication, request body construction, signature generation using hash('sha256'), and making the API call with cURL. ```php <?php $apiToken = 'your_api_token'; $apiSecret = 'your_api_secret'; $requestBody = json_encode([ 'subscription_id' => 'unlimited_energy', 'external_id' => 'my-subscription-123', 'params' => [ 'address' => 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t', 'duration' => 30, 'transactions_limit' => 0, 'activate_address' => true ] ]); // Calculate signature $signature = hash('sha256', $requestBody . $apiSecret); // Execute API request $ch = curl_init('https://api.tronzap.com/v1/subscription/start'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $requestBody); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer ' . $apiToken, 'X-Signature: ' . $signature, 'Content-Type: application/json' ]); $response = curl_exec($ch); curl_close($ch); echo $response; ?> ``` -------------------------------- ### POST /v1/subscription/start Source: https://docs.tronzap.com/api Initiates a new subscription. ```APIDOC ## POST /v1/subscription/start ### Description Start a new subscription. ### Method POST ### Endpoint /v1/subscription/start ``` -------------------------------- ### Fetch Available Subscriptions (Python) Source: https://docs.tronzap.com/api/subscriptions.html This Python example uses the requests library to call the /v1/subscriptions API. It computes the SHA256 signature and includes it in the request headers. Ensure you replace the placeholder API token and secret. ```python import hashlib import json import requests api_token = 'your_api_token' api_secret = 'your_api_secret' request_body = json.dumps({}) # Calculate signature signature = hashlib.sha256((request_body + api_secret).encode()).hexdigest() # Execute API request headers = { 'Authorization': f'Bearer {api_token}', 'X-Signature': signature, 'Content-Type': 'application/json' } response = requests.post( 'https://api.tronzap.com/v1/subscriptions', headers=headers, data=request_body ) print(response.json()) ``` -------------------------------- ### Get Direct Recharge Info Source: https://docs.tronzap.com/api/direct-recharge-info.html Returns information about the direct energy recharge service. This endpoint is public and does not require authentication. ```APIDOC ## POST /v1/direct-recharge-info ### Description Returns information about direct energy recharge service. After sending TRX to the specified address, the sender will receive delegated energy proportional to the amount of TRX sent. ### Method POST ### Endpoint /v1/direct-recharge-info ### Parameters No parameters are required for this request. ### Response #### Success Response (200) - **code** (integer) - Response code (0 = success) - **request_id** (string) - Unique request identifier - **result** (object) - Response data - **result.address** (string) - TronZap's public wallet address for direct recharge - **result.rates** (array) - List of available energy rate tiers - **result.rates[].duration** (integer) - Duration in hours (always 1) - **result.rates[].min_energy** (integer) - Minimum energy amount - **result.rates[].max_energy** (integer) - Maximum energy amount - **result.rates[].price** (float) - Price per 1000 energy - **result.rates[].price_32k** (float) - Price for 32k energy - **result.rates[].price_65k** (float) - Price for 65k energy - **result.rates[].price_131k** (float) - Price for 131k energy ### Response Example ```json { "code": 0, "request_id": "bbf74bcd-fb36-4df8-adc8-25f2bacd087b", "result": { "address": "TRONZAP_PUBLIC_TRX_ADDRESS", "rates": [ { "duration": 1, "min_energy": 50000, "max_energy": 131000, "price": 0.052300000, "price_32k": 1.67, "price_65k": 3.4, "price_131k": 6.85 } ] } } ``` ### Possible Errors - **35** (`service_unavailable`) - Service not available - **500** (`internal_server_error`) - Internal server error ``` -------------------------------- ### Start Subscription with Unlimited Duration and Transaction Limit (Bash) Source: https://docs.tronzap.com/api/subscription-start.html This Bash snippet shows how to create a subscription with an unlimited duration (0 days) and a specific transaction limit. It details the request body structure and the cURL command for execution. ```bash #!/bin/bash API_TOKEN="your_api_token" API_SECRET="your_api_secret" REQUEST_BODY='{ "subscription_id": "unlimited_energy", "params": { "address": "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t", "duration": 0, "transactions_limit": 100 } }' # Calculate signature SIGNATURE=$(echo -n "${REQUEST_BODY}${API_SECRET}" | sha256sum | cut -d' ' -f1) # Execute API request curl -X POST "https://api.tronzap.com/v1/subscription/start" \ -H "Authorization: Bearer ${API_TOKEN}" \ -H "X-Signature: ${SIGNATURE}" \ -H "Content-Type: application/json" \ -d "${REQUEST_BODY}" ```