Skip to main content

Python SDK

PyPI version Python License: MIT Official Python SDK for the Paratro MPC Wallet Gateway.

Installation

pip install paratro-sdk
Requirements: Python 3.9 or higher. New wallets are created asynchronously. Wait until both status and key_status are ACTIVE before creating accounts or transfers. The gateway derives account network automatically from the selected chain.

Quick Start

from paratro import (
    MPCClient, Config,
    CreateWalletRequest, CreateAccountRequest,
    CreateAssetRequest, CreateTransferRequest,
)

# Initialize client
client = MPCClient("your-api-key", "your-api-secret", Config.production())

# Create wallet
wallet = client.create_wallet(CreateWalletRequest(wallet_name="My Wallet"))
print(f"Wallet ID: {wallet.wallet_id}")

# Create account
account = client.create_account(CreateAccountRequest(
    wallet_id=wallet.wallet_id,
    chain="ethereum",
    label="Deposit Account",
))
print(f"Account: {account.account_id} ({account.address})")

# Add asset
asset = client.create_asset(CreateAssetRequest(
    account_id=account.account_id,
    symbol="USDT",
    chain="ethereum",
))
print(f"Asset: {asset.asset_id} ({asset.symbol})")

# Create transfer
transfer = client.create_transfer(CreateTransferRequest(
    from_address=account.address,
    to_address="0xbbbb...",
    chain="ethereum",
    token_symbol="USDT",
    amount="10.5",
))
print(f"Transfer: {transfer.tx_id} ({transfer.status})")

Configuration

# Sandbox: https://api-sandbox.paratro.com
client = MPCClient(api_key, api_secret, Config.sandbox())

Methods

The SDK provides direct methods on the client:
CategoryMethods
Walletcreate_wallet, get_wallet, list_wallets
Accountcreate_account, get_account, list_accounts
Assetcreate_asset, get_asset, list_assets
Transactionget_transaction, list_transactions
Transfercreate_transfer

Error Handling

The SDK raises APIError for API failures with structured error information:
from paratro import APIError, is_not_found, is_auth_error, is_rate_limited

try:
    wallet = client.get_wallet(wallet_id)
except APIError as e:
    if is_not_found(e):
        print("Wallet not found")
    elif is_auth_error(e):
        print("Authentication failed")
    elif is_rate_limited(e):
        print("Rate limited, retry later")
For detailed error inspection:
try:
    asset = client.create_asset(req)
except APIError as e:
    print(f"HTTP {e.http_status}")
    print(f"Code: {e.code}")
    print(f"Type: {e.error_type}")
    print(f"Message: {e.message}")

    if e.code == "asset_already_exists":
        print("Asset already added to this account")
    elif e.code == "account_not_active":
        print("Account is not active")

Helper Functions

FunctionDescription
is_not_found(err)Detects 404 responses
is_rate_limited(err)Identifies 429 rate-limit responses
is_auth_error(err)Catches 401/403 permission issues
See Error Handling Guide for more patterns.

Pagination

List methods return a PaginatedResponse with items, total, and has_more:
from paratro import ListTransactionsRequest

resp = client.list_transactions(ListTransactionsRequest(
    wallet_id=wallet.wallet_id,
    page=1,
    page_size=20,
))

for tx in resp.items:
    print(f"TX: {tx.tx_hash} {tx.amount} {tx.token_symbol} ({tx.status})")

if resp.has_more:
    # Fetch next page
    pass

print(f"Total: {resp.total}")

Authentication

The SDK handles JWT authentication automatically:
  1. On the first API call, the client exchanges your api_key and api_secret for a JWT token
  2. The token is cached and reused for subsequent requests
  3. When the token approaches expiration (< 5 minutes remaining), it is automatically refreshed
  4. Token management is thread-safe for concurrent usage

Project Structure

paratro-sdk-python/
├── paratro/
│   ├── __init__.py     # Public API exports
│   ├── client.py       # MPCClient with all API methods
│   ├── config.py       # Environment configuration
│   ├── errors.py       # APIError and helper functions
│   └── models.py       # Request/response dataclasses
├── tests/
│   └── test_client.py  # Unit tests
└── pyproject.toml      # Package metadata