tronsave (Python)
Fully-typed Python SDK for the Tronsave v2 API (TRON Energy & Bandwidth).
Python 3.9+, built on httpx.
Install
pip install tronsave
Quick start
import os
from tronsave import TronsaveClient, Network
sdk = TronsaveClient(api_key=os.environ["TRONSAVE_API_KEY"], network=Network.MAINNET)
me = sdk.get_user_info()
print(me.balance, "SUN")
est = sdk.estimate_buy_resource({
"receiver": "TFwUFWr3QV376677Z8VWXxGUAMFSrq1MbM",
"resourceType": "ENERGY",
"resourceAmount": 65000, # ENERGY must be > 64000
"durationSec": 3600,
})
order = sdk.buy_resource(
{"receiver": "TFwUFWr3QV376677Z8VWXxGUAMFSrq1MbM", "resourceAmount": 65000, "durationSec": 3600},
{"allowPartialFill": True, "maxPriceAccepted": 100},
)
status = sdk.get_order(order.order_id)
print(status.fulfilled_percent) # 100 = fully delegated
Errors
All exceptions subclass tronsave.TronsaveError (.code, .status, .raw):
TronsaveAuthError (401), TronsaveValidationError / TronsaveBusinessError (400),
TronsaveRateLimitError (429, .retry_after_ms), TronsaveNetworkError (transport).
from tronsave import TronsaveBusinessError, TronsaveRateLimitError
try:
sdk.buy_resource({"receiver": "T...", "resourceAmount": 65000})
except TronsaveRateLimitError as e:
print("retry after", e.retry_after_ms, "ms")
except TronsaveBusinessError as e:
print(e.code, e.status)
Notes
- Defaults:
ENERGY,MEDIUM,durationSec=259200. - ENERGY
resourceAmountmust be > 64000 (rejected client-side). extendTois a Unix timestamp in seconds.- Rate limits enforced client-side (15/s; 1/s for
get_extendable_delegates).
Develop
pip install -e ".[dev]"
pytest # runs the shared conformance suite (needs Node.js for the mock server)
See ../../spec/PARITY.md for cross-language parity.
Metadata
Release files for tronsave 2.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tronsave-2.0.0.tar.gz | 9.2 kB | Without provenance | Details for tronsave-2.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tronsave-2.0.0-py3-none-any.whl | Python 3 | none | any | Details for tronsave-2.0.0-py3-none-any.whl |
Total release size: 19.9 kB
Release files / tronsave-2.0.0.tar.gz
| Download URL | tronsave-2.0.0.tar.gz |
|---|---|
| Size | 9.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2b5085ca89a1b8e1533a69a100530476ef80113b3909479e19e47bd7e12adee7
|
|
BLAKE2b-256 checksum How to use checksums |
d2a38d8644fe9743de23d0d5b714fea2056fc16804d2ee157ba01aaf88325063
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.3
|
Release files / tronsave-2.0.0-py3-none-any.whl
| Download URL | tronsave-2.0.0-py3-none-any.whl |
|---|---|
| Size | 10.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b23b05080cdadd0ff313bedaabde63bf80bc89d3681fc37ccbb8518511c33d17
|
|
BLAKE2b-256 checksum How to use checksums |
1a4cb3df2abf31501f0cbeaed39fab80e57e1432496712e16c4d5836ce31786e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.3
|
Security for tronsave 2.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.