Skip to main content

granthe

Official Python SDK for Granthe — institutional liquidity rail for crypto settlement.

PyPI Python

Install

pip install granthe

Quick Start

from granthe import Granthe

granthe = Granthe(api_key="vf_live_...", webhook_secret="whsec_...")

# Create a payment invoice
invoice = granthe.invoices.create(
    amount=100.00,
    currency="USDT",
    network="tron",
    description="Premium Plan",
    customer_email="buyer@example.com",
)
print(f"Pay to: {invoice.wallet_address}")
print(f"Status: {invoice.status}")

# Request a payout
payout = granthe.payouts.create(
    amount=50.00,
    currency="USDT",
    network="tron",
    destination="TXyz...recipientAddress",
)
print(f"Payout ID: {payout.id}")

Async Support

from granthe import AsyncFlow

async with AsyncFlow(api_key="vf_live_...") as flow:
    invoice = await granthe.invoices.create(
        amount=100, currency="USDT", network="ethereum",
    )

Resources

Invoices

# Create
invoice = granthe.invoices.create(amount=100, currency="USDT", network="tron")

# Get by ID
invoice = granthe.invoices.get("inv_abc123")

# List with filters
result = granthe.invoices.list(status="paid", page=1, limit=20)
for inv in result.items:
    print(inv.id, inv.amount, inv.status)

# Cancel
granthe.invoices.cancel("inv_abc123")

Payouts

# Single payout
payout = granthe.payouts.create(
    amount=50, currency="USDT", network="tron",
    destination="TXyz...addr",
)

# Batch payout
payouts = granthe.payouts.create_batch([
    {"amount": 50, "currency": "USDT", "network": "tron", "destination_address": "TXyz..."},
    {"amount": 25, "currency": "USDT", "network": "tron", "destination_address": "TAbc..."},
])

# Check status
payout = granthe.payouts.get("pout_abc123")

Wallets

# Generate a new deposit wallet
wallet = granthe.wallets.generate(network="ethereum", currency="USDT")
print(wallet.address)

# List wallets
result = granthe.wallets.list(network="tron")

# Check balance
wallet = granthe.wallets.balance("wal_abc123")

Swaps

# Get a quote
quote = flow.swaps.quote("BTC", "USDT", amount=0.01)
print(f"Rate: {quote.rate}, You get: {quote.to_amount} USDT")

# Execute swap
swap = flow.swaps.create("BTC", "USDT", amount=0.01)

Webhooks

from granthe import Granthe, InvalidSignatureError

granthe = Granthe(api_key="vf_live_...", webhook_secret="whsec_...")

# In your webhook handler:
def handle_webhook(request):
    payload = request.body
    signature = request.headers["X-Granthe-Signature"]

    try:
        event = flow.webhooks.verify(payload, signature)
    except InvalidSignatureError:
        return {"error": "Invalid signature"}, 400

    if event.type == "invoice.paid":
        invoice_id = event.data["id"]
        print(f"Invoice {invoice_id} paid!")

    return {"status": "ok"}

Error Handling

from granthe import Granthe, FlowError, AuthenticationError, RateLimitError

granthe = Granthe(api_key="vf_live_...")

try:
    invoice = granthe.invoices.create(amount=100, currency="USDT", network="tron")
except AuthenticationError:
    print("Bad API key")
except RateLimitError as e:
    print(f"Rate limited, retry after {e.retry_after}s")
except FlowError as e:
    print(f"Error: {e.message} (code={e.code}, status={e.status})")

Configuration

granthe = Granthe(
    api_key="vf_live_...",
    webhook_secret="whsec_...",      # For webhook verification
    base_url="https://api.granthe.io/api/v1",  # Default
    timeout=30.0,                     # Request timeout in seconds
)

Supported Networks

Bitcoin, Ethereum, Tron, BNB Chain, Solana, Ripple, Polygon, Avalanche, Dogecoin, Litecoin, TON, and more.

License

MIT

Metadata

Release files for granthe 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for granthe 0.6.0
File Size Uploaded Provenance
granthe-0.6.0.tar.gz 12.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for granthe 0.6.0
File Interpreter ABI Platform
granthe-0.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 29.8 kB

Release files / granthe-0.6.0.tar.gz

Download URL granthe-0.6.0.tar.gz
Size 12.8 kB
Tags Source
SHA-256 checksum
How to use checksums
624506cd042b75c7f916b68f186b3ef31e68b4634f78810e6519e624d01812c2
BLAKE2b-256 checksum
How to use checksums
09e9c3d4b247fa5f50c4f8f1612bdc6ad126e63b635cd65e52dfcc7b3e1afbad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Release files / granthe-0.6.0-py3-none-any.whl

Download URL granthe-0.6.0-py3-none-any.whl
Size 17.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1df70653500048a9cd1b52db626f0ad6f2629b562c4b11338bde29381eccccc9
BLAKE2b-256 checksum
How to use checksums
72b1c53f4996d8605ed5fadbfebd69058d0bfadc095ec3fce49115eb06e0e5d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.3

Security for granthe 0.6.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.

Release history Release notifications | RSS feed

This release

0.6.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page