Wallgent
Integrations

Get Started with the Wallgent Python SDK

Install the Python SDK and make your first wallet, payment, and balance check.

Coming Soon: The Wallgent Python SDK is currently in development. This guide shows the planned API so you can design your integration today. Use the REST fallback section below to get started now.

Prerequisites

1. Install

pip install wallgent

2. Initialize the Client

from wallgent import Wallgent

wg = Wallgent(api_key="wg_test_your_key_here")

3. Create and Fund a Wallet

# Create a wallet
wallet = wg.wallets.create(name="my-agent", agent_name="demo-bot")
print(f"Wallet: {wallet.id}")

# Fund it
wg.wallets.fund(wallet.id, amount="100.00")

4. Send a Payment

txn = wg.payments.send(
    from_wallet=wallet.id,
    to_wallet="wal_vendor_01",
    amount="25.00",
    description="API subscription",
)
print(f"Payment: {txn.id}{txn.state}")

5. Check Balance

balance = wg.wallets.get_balance(wallet.id)
print(f"Available: ${balance.available}")
print(f"Pending:   ${balance.pending}")

6. Error Handling

from wallgent.exceptions import InsufficientFundsError, PolicyDeniedError

try:
    wg.payments.send(
        from_wallet=wallet.id,
        to_wallet="wal_vendor_01",
        amount="999999.00",
    )
except InsufficientFundsError as e:
    print(f"Not enough funds: {e.available} available")
except PolicyDeniedError as e:
    print(f"Blocked by policy: {e.policy_name}{e.reason}")

7. Async Usage

import asyncio
from wallgent import AsyncWallgent

async def main():
    wg = AsyncWallgent(api_key="wg_test_your_key_here")
    balance = await wg.wallets.get_balance("wal_ops")
    print(f"Available: ${balance.available}")

asyncio.run(main())

REST Fallback

You can use Wallgent from Python today via the REST API:

import requests

API_KEY = "wg_test_your_key_here"
BASE = "https://api.wallgent.com"
HEADERS = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json",
}

# Create a wallet
resp = requests.post(f"{BASE}/v1/wallets", headers=HEADERS, json={"name": "my-agent"})
wallet = resp.json()

# Fund it
requests.post(f"{BASE}/v1/wallets/{wallet['id']}/fund", headers=HEADERS, json={"amount": "100.00"})

# Send a payment
resp = requests.post(
    f"{BASE}/v1/payments",
    headers=HEADERS,
    json={"from": wallet["id"], "to": "wal_vendor_01", "amount": "25.00"},
)
print(resp.json())

Next Steps

On this page