Integrations
Python SDK
The same operations and reason codes as the TypeScript SDK; a test runs both against one service and compares the outcomes.
import json, os
from tollex import TollexClient, TollexTools, PolicyEngine
net, key = os.environ["TOLLEX_NETWORK"], open(os.environ["TOLLEX_WALLET_KEY_FILE"]).read().strip()
policy = PolicyEngine(agent_id="me", networks=[net], assets=[{"network": net, "address": os.environ["TOLLEX_USDG"]}], max_per_request=10_000)
tollex = TollexTools(TollexClient(key, policy, require_receipt=True), os.environ["TOLLEX_URL"])
done = tollex.do("ETH-USD spot price", {"pair": "ETH-USD"})
print(json.dumps({"result": done.result, "charged": str(done.charged), "receipt": done.receipt_valid}))Errors are subclasses of TollexError with the same reason values. do() accepts operation_id (safe retries) and correlation_id; AsyncTollexTools offers the same API for asyncio. Python 3.10 or newer is recommended.
The packages are not on public registries yet. During onboarding you receive tarballs and a wheel; install them from the files, for example
npm install ./tollex-client-0.2.0.tgz.