Skip to main content

Official Python SDK for the Tron Energy API by TronZap.com. Buy Tron energy for cheap USDT transfers on TronZap.com

Project description

TronZap SDK for Python

English | Español | Português | Русский

Official Python SDK for the TronZap API. This SDK allows you to easily integrate with TronZap services for TRON energy rental.

TronZap.com allows you to buy TRON energy, making USDT (TRC20) transfers cheaper by significantly reducing transaction fees.

👉 Register for an API key to start using TronZap API and integrate it via the SDK.

Installation

pip install tronzap-sdk

Quick Start

from tronzap_sdk import Client

# Initialize the client
client = Client(
    api_token="your_api_token",
    api_secret="your_api_secret"
)

# Get available services
services = client.get_services()
print(services)

# Get account balance
balance = client.get_balance()
print(balance)

# Estimate energy cost for USDT transfer
estimate = client.estimate_energy('FROM_TRX_ADDRESS', 'TO_TRX_ADDRESS', 'TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t')
print(estimate)

# Calculate energy cost
calculation = client.calculate(
    address="TRON_WALLET_ADDRESS",
    energy=65150  # Recommended amount for USDT transfers
)
print(calculation)

# Create energy transaction
transaction = client.create_energy_transaction(
    address="TRON_WALLET_ADDRESS",
    energy_amount=65150, # From 32000
    duration=1, # Possible values 1 or 24 hours
    activate_address=True  # If the address needs activation
)
print(transaction)

# Check transaction status
status = client.check_transaction(id="TRANSACTION_ID")
print(status)

# Get direct recharge information
recharge_info = client.get_direct_recharge_info()
print(recharge_info)

Features

  • Get available services
  • Get account balance
  • Calculate energy cost
  • Create address activation transactions
  • Create energy purchase transactions
  • Check transaction status
  • Get direct recharge information

Requirements

  • Python 3.7 or higher
  • requests >= 2.25.0

Error Handling

The SDK raises TronZapException when the API returns an error. Each exception includes a .code and a .message property for debugging and handling specific cases.

Example

from tronzap_sdk import Client, TronZapException, ErrorCode

client = Client(api_token="your_api_token", api_secret="your_api_secret")

try:
    balance = client.get_balance()
except TronZapException as e:
    if e.code == ErrorCode.AUTH_ERROR:
        print("Authentication error")
    elif e.code == ErrorCode.INVALID_SERVICE_OR_PARAMS:
        print("Invalid service or parameters")
    elif e.code == ErrorCode.WALLET_NOT_FOUND:
        print("Internal wallet not found. Contact support.")
    elif e.code == ErrorCode.INSUFFICIENT_FUNDS:
        print("Insufficient funds")
    elif e.code == ErrorCode.INVALID_TRON_ADDRESS:
        print("Invalid TRON address")
    elif e.code == ErrorCode.INVALID_ENERGY_AMOUNT:
        print("Invalid energy amount")
    elif e.code == ErrorCode.INVALID_DURATION:
        print("Invalid duration")
    elif e.code == ErrorCode.TRANSACTION_NOT_FOUND:
        print("Transaction not found")
    elif e.code == ErrorCode.ADDRESS_NOT_ACTIVATED:
        print("Address not activated")
    elif e.code == ErrorCode.ADDRESS_ALREADY_ACTIVATED:
        print("Address already activated")
    elif e.code == ErrorCode.INTERNAL_SERVER_ERROR:
        print("Internal server error")
    else:
        print(f"Unhandled error {e.code}: {e.message}")

Error Codes

Code Constant Description
1 AUTH_ERROR Authentication error – Invalid API token or signature
2 INVALID_SERVICE_OR_PARAMS Invalid service or parameters
5 WALLET_NOT_FOUND Internal wallet not found. Contact support.
6 INSUFFICIENT_FUNDS Insufficient funds
10 INVALID_TRON_ADDRESS Invalid TRON address
11 INVALID_ENERGY_AMOUNT Invalid energy amount
12 INVALID_DURATION Invalid duration
20 TRANSACTION_NOT_FOUND Transaction not found
24 ADDRESS_NOT_ACTIVATED Address not activated
25 ADDRESS_ALREADY_ACTIVATED Address already activated
500 INTERNAL_SERVER_ERROR Internal server error – Contact support

Support

For support, please contact us on Telegram: @tronzap_bot

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tronzap_sdk-1.0.5.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

tronzap_sdk-1.0.5-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file tronzap_sdk-1.0.5.tar.gz.

File metadata

  • Download URL: tronzap_sdk-1.0.5.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for tronzap_sdk-1.0.5.tar.gz
Algorithm Hash digest
SHA256 1110c86aad25f4a9bc0913a453e37aef2c991fc1f95bc63c432b1849ee025c4b
MD5 c964adb42cf9f603f1de143d7dfce174
BLAKE2b-256 34d498f21ee2997027cb2908498df93e0751e47b9166af72a06173b06cfe2d29

See more details on using hashes here.

File details

Details for the file tronzap_sdk-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: tronzap_sdk-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for tronzap_sdk-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 5f5c2fb44d51962d47bd21deb1f2f91587fa3a0e84ad24c3ff975d6da834d461
MD5 7df723f9d249df680be2242858221607
BLAKE2b-256 dff5e64472b2b4342cbcdf7c9d48c179ddb17c7995a939675d0c1638b4464b9b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page