Whire Python SDK
The Whire Python SDK provides convenient access to the Whire Payments API from Python applications. It includes support for instant payments, direct debit mandates, and a built-in agent toolkit for LLMs.
Note: This SDK is currently in sandbox mode. All data and transactions are simulated — no real money is moved. To get sandbox API keys, email support@whire.ai.
Requirements
- Python 3.11+
Installation
pip install whire
Usage
Instant payments
from whire import WhireClient, Environment
async with WhireClient(api_key="whire_sk_...", environment=Environment.SANDBOX) as client:
# Create a recipient (stores their bank details securely)
recipient = await client.create_recipient(
name="John Doe",
account_number="FR7630006000011234567890189",
)
# Send a payment
result = await client.pay(
recipient_id=recipient.recipient_id,
amount="50.00",
label="Invoice #42",
)
# The user must approve the payment by visiting the consent URL.
if result.consent.requires_consent:
print(f"Approve payment: {result.consent.consent_url}")
# Poll until the payment settles.
status = await client.get_payment_status(result.transaction_id)
Balance and transaction history
balance = await client.get_balance()
print(f"Available: {balance.available} {balance.available_currency}")
transactions = await client.get_transactions(limit=10)
for t in transactions.transactions:
print(f"{t.created_at} {t.side:>5} {t.amount} {t.currency} {t.label}")
Recipients
# Search for existing recipients
results = await client.list_recipients(search="John")
for r in results.items:
print(f"{r.recipient_id} {r.name} {r.label}")
# Get a specific recipient
recipient = await client.get_recipient("a1b2c3d4-...")
Direct debit
Create a recipient and mandate once, then collect payments without per-transaction approval.
recipient = await client.create_recipient(
name="Jane Doe",
account_number="DE89370400440532013000",
country="DEU",
)
mandate = await client.create_mandate(recipient_id=recipient.recipient_id)
debit = await client.debit(
mandate_id=mandate.mandate_id,
amount="25.00",
label="Monthly subscription",
)
# Settlement takes 1-2 business days.
Configuration
The client accepts the following options:
| Parameter | Default | Description |
|---|---|---|
api_key |
required | Your Whire API key |
environment |
Environment.PRODUCTION |
PRODUCTION or SANDBOX |
custom_base_url |
None |
Override for local testing (localhost only) |
timeout |
30.0 |
HTTP timeout in seconds |
max_retries |
3 |
Max retry attempts on 429 / 5xx / network errors |
retry_base_delay |
0.5 |
Base delay (seconds) for exponential backoff |
AI agent toolkit
WhireToolkit wraps the client into a tool-calling interface compatible with OpenAI, Anthropic, and other function-calling LLMs.
from whire import WhireToolkit, Environment
async with WhireToolkit(api_key="whire_sk_...", environment=Environment.SANDBOX) as toolkit:
# Inject into your agent
system_prompt = toolkit.system_prompt
tools = toolkit.get_tools()
# Execute tool calls returned by the model
recipient = await toolkit.execute("create_recipient", {
"name": "John Doe",
"account_number": "FR7630006000011234567890189",
})
result = await toolkit.execute("send_payment", {
"recipient_id": recipient["recipient_id"],
"amount": "50.00",
"label": "Invoice #42",
})
Available tools
| Tool | Description | Requires user approval | Settlement |
|---|---|---|---|
create_recipient |
Store recipient bank details | No | — |
list_recipients |
List or search recipients | No | — |
get_recipient |
Get recipient details | No | — |
send_payment |
Send an instant payment | Yes (consent URL) | Seconds |
get_payment_status |
Check payment status | No | — |
get_balance |
Check account balance | No | — |
get_transactions |
View transaction history | No | — |
create_mandate |
Create a direct debit mandate | No | — |
debit_payment |
Collect via an existing mandate | No | 1-2 days |
MCP server (Claude Desktop)
The SDK ships with a built-in MCP server for Claude Desktop and other MCP-compatible clients.
Add to your Claude Desktop config (claude_desktop_config.json):
{
"mcpServers": {
"whire": {
"command": "python",
"args": ["-m", "whire.mcp_server"],
"env": {
"WHIRE_API_KEY": "whire_sk_..."
}
}
}
}
Error handling
All errors inherit from WhireError and include structured metadata that agents can use to decide what to do next.
from whire import WhireError, AuthenticationError
try:
result = await client.pay(...)
except AuthenticationError:
# Invalid or expired API key (HTTP 401)
...
except WhireError as e:
print(e.message) # Human-readable message
print(e.error_code) # Machine-readable code
print(e.status_code) # HTTP status code (if applicable)
print(e.is_retryable) # Safe to retry?
print(e.is_input_error) # Bad parameters — fix and retry
print(e.needs_user_action) # User must do something (e.g. add funds)
Exception types
| Exception | When |
|---|---|
AuthenticationError |
Invalid API key |
PaymentError |
Payment request fails |
MandateError |
Mandate operation fails |
ValidationError |
Invalid parameters (HTTP 422) |
WhireError |
Everything else |
License
MIT
Release files for whire 0.1.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 | |
|---|---|---|---|
| whire-0.1.0.tar.gz | 24.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| whire-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 44.1 kB
Release files / whire-0.1.0.tar.gz
| Download URL | whire-0.1.0.tar.gz |
|---|---|
| Size | 24.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9b6d11d4bf48989321043c0bac2fcb20111b6c7ff83db9365679f9e6a2a6c1a3
|
|
BLAKE2b-256 checksum How to use checksums |
4f4692d63535fa79ab6acfa97ca2a5afb61d7b6c82d9c681ca9a5440bdf77dc8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Release files / whire-0.1.0-py3-none-any.whl
| Download URL | whire-0.1.0-py3-none-any.whl |
|---|---|
| Size | 20.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4b8def4b650f58f6ad0952ae67a3cc91973a844713c653d0bbb6b7d0d8989860
|
|
BLAKE2b-256 checksum How to use checksums |
7e737532bab5de396857810c9dbdbc72c278c5bfdc296a086b7051f3e8c0b41e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|