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

Check out at PyPI: https://pypi.org/project/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 60000
    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.7.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: tronzap_sdk-1.0.7.tar.gz
  • Upload date:
  • Size: 9.4 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.7.tar.gz
Algorithm Hash digest
SHA256 5a2143fc8750f843039e4173cf48310c162592f4071e66dab93f0b4035b0508c
MD5 930ca33e8ad75a6f1a367158bc714a7b
BLAKE2b-256 7e2e297fb7f31aea8d5f70a77ed587a0ad293606172328842b9d280a7b8877ef

See more details on using hashes here.

File details

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

File metadata

  • Download URL: tronzap_sdk-1.0.7-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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 21d1a8b808c73d0572d51b799b6c41ed0ec606982aa9f40dc091837023beb5f2
MD5 96c28540f354205c2c149a6b1ba40667
BLAKE2b-256 e4cca5137a8d25a8df235e5e2d8910959baed04aa88317b91dda234bd129db09

See more details on using hashes here.

Supported by

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