Python SDK for TonWise — Trust & Safety API for the TON blockchain
Project description
TonWise Python SDK
Python SDK for TonWise — Trust & Safety API for the TON blockchain. Detect rug pulls, sybil clusters, contract spoofing, and drainer activity in 3 lines of code.
pip install tonwise
Quickstart
from tonwise import TonWiseClient
with TonWiseClient(api_key="tg_live_xxx") as client:
result = client.scan("EQA1234567...")
print(f"Safe: {result.is_safe}, Dump probability: {result.dump_probability}%")
Async usage
For AI agents, trading bots, and FastAPI / aiohttp services:
import asyncio
from tonwise import AsyncTonWiseClient
async def main():
async with AsyncTonWiseClient(api_key="tg_live_xxx") as client:
result = await client.scan("EQA1234567...")
print(f"Safe: {result.is_safe}, Sybils: {result.sybil_clusters}")
asyncio.run(main())
Webhooks
Subscribe to real-time security events. Supported event types:
scam— confirmed scam contractspoof— confusable / invisible-character token spoofingdump_alert— high dump probability (>70%)sybil_cluster— coordinated wallet activitypump_warning— pump-and-dump pattern detectedmanifest_forgery— fake jetton metadataw5_batch_drain— drainer activity via W5 batch transfers*— subscribe to all events
client.register_webhook(
url="https://your-app.com/tonwise-callback",
events=["scam", "dump_alert"],
)
# List your webhooks
hooks = client.list_webhooks()
# Disable a webhook
client.delete_webhook(webhook_id=42)
Verify HMAC-SHA256 signatures
Every webhook payload is signed with the secret returned at registration:
import hmac, hashlib
def verify_signature(secret: str, body: bytes, signature_header: str) -> bool:
expected = hmac.new(secret.encode(), body, hashlib.sha256).hexdigest()
received = signature_header.removeprefix("sha256=")
return hmac.compare_digest(received, expected)
Error handling
The SDK raises typed exceptions so you can branch cleanly:
from tonwise import TonWiseClient, AuthError, RateLimitError, APIError
try:
result = client.scan("EQA1234...")
except AuthError:
# 401 — bad or revoked API key
...
except RateLimitError as e:
# 429 — wait e.retry_after seconds and retry
time.sleep(e.retry_after)
except APIError as e:
# other 4xx / 5xx — inspect e.status_code and e.body
...
Features
- Sync (
requests) and async (aiohttp) clients — both first-class - Webhook management: register / list / delete
- Type hints + Pydantic v2 response models
- Rate-limit aware:
RateLimitError.retry_afterexposes the server's hint - Custom
base_urlfor staging environments
Get an API key
Visit tonguard.app/pricing. The free tier gives 1 000 calls/day — no credit card required.
| Tier | Calls/day | Webhooks | Price |
|---|---|---|---|
| Free | 1 000 | 1 | $0 |
| Pro | 50 000 | 5 | $99/month |
| Business | 250 000 | 10 | $499/month |
| Enterprise | unlimited | 10+ | custom |
Development
git clone https://github.com/tonwise/tonwise-python
cd tonwise-python
pip install -e ".[dev]"
pytest
License
MIT — see LICENSE.
Links
- 🌐 Website: https://tonguard.app
- 📖 API docs: https://tonguard.app/docs
- 📡 Threat Intel channel: https://t.me/tonwise_intel
- 🐛 Issues: https://github.com/tonwise/tonwise-python/issues
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tonwise-0.2.0.tar.gz.
File metadata
- Download URL: tonwise-0.2.0.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d01c1f0f3319c29066313f16f1f88fe7ff880cee8fca80291d6fe72896041d3
|
|
| MD5 |
60415cd77ccb903bfe426ccd5d7411de
|
|
| BLAKE2b-256 |
8608f201def6bbccd560e6f19d28caab02f486a7c5eca29047df89d1b38ee3a1
|
File details
Details for the file tonwise-0.2.0-py3-none-any.whl.
File metadata
- Download URL: tonwise-0.2.0-py3-none-any.whl
- Upload date:
- Size: 11.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec06358a684a7f8ade9df14c7bf5a7f9874084b3875a80f2344712de6242f714
|
|
| MD5 |
be0fd4368ac8f784b697f10d187f3466
|
|
| BLAKE2b-256 |
a15e23acdf0999d27c074d005cbd621d7702ec1194165f1fca438b204c548824
|