Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

swiftpay-api-client

Python SDK for the SwiftPay REST API. Sync and async, type-checked end-to-end with Pydantic v2.

  • Two transports. SwiftPay for sync code, AsyncSwiftPay for asyncio (FastAPI, async workers).
  • Auth-aware modules. Methods that need a secret key raise SwiftPayConfigError at call time when the key is missing — no silent 401s.
  • Typed errors. Each HTTP status maps to a discriminated subclass.
  • Two runtime deps. httpx and pydantic.

Install

pip install swiftpay-api-client

Requires Python 3.10+.

Quick start

from swiftpay import SwiftPay

client = SwiftPay(secret_key="sk_live_...")

result = client.invoices.create(
    amount="100.00",
    token="USDC",
    network="ethereum",
    recipients={"evm": "0xYourWallet..."},
    external_ref="order_8675309",
)
print("New" if result.created else "Existing", result.invoice.id)

Async

import asyncio
from swiftpay import AsyncSwiftPay

async def main() -> None:
    async with AsyncSwiftPay(secret_key="sk_live_...") as client:
        chains = await client.utils.list_chains()
        for c in chains:
            print(c.id, c.chain_id)

asyncio.run(main())

Configuration

SwiftPay(
    secret_key="sk_live_...",                 # optional — required only for secret-scoped modules
    base_url="https://api.swiftpay.finance",  # optional, defaults to production
    timeout=30.0,                              # optional, seconds
    http_client=...,                           # optional, inject your own httpx.Client
)

Modules

Module Auth Methods
client.utils none list_chains, list_tokens
client.invoices secret key create, list, get, list_transactions, rescan
client.x402.facilitator none supported, verify, settle, payment_status
client.x402.endpoints secret key register, list, deactivate, requirements, requirements_by_id

x402.facilitator.settle() returns a SettlementResponse for both 200 (settled) and 422 (settlement failed). Inspect result.success / result.error. Other 4xx / 5xx still raise.

Error handling

from swiftpay import SwiftPay
from swiftpay.errors import (
    SwiftPayError,
    SwiftPayValidationError,
    SwiftPayAuthError,
    SwiftPayNotFoundError,
    SwiftPayConfigError,
    SwiftPayServerError,
)

client = SwiftPay(secret_key="sk_live_...")

try:
    client.invoices.create(amount="", token="USDC", network="ethereum")
except SwiftPayValidationError as e:
    print("Bad input:", e.details)
except SwiftPayAuthError:
    print("Bad API key")
except SwiftPayError as e:
    print("SwiftPay error", e.status, e, e.trace_id)

Versioning

This SDK is pinned to one major version of the SwiftPay REST API. Each swiftpay-api-client major maps 1:1 to a SwiftPay API major.

SDK API path prefix
0.x / 1.x /v1/...

When SwiftPay ships /v2, we'll release swiftpay-api-client@2.0.0 with regenerated types. Within a major, we follow SemVer.

Development

uv venv
source .venv/bin/activate
uv pip install -e ".[dev]"
ruff check .
ruff format --check .
mypy src
pytest --cov
python -m build

License

Licensed under the Apache License, Version 2.0. See LICENSE for details.

Metadata

Release files for swiftpay-api-client 0.1.1b0

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

Source distribution (sdist)

Source distribution for swiftpay-api-client 0.1.1b0
File Size Uploaded Provenance Actions
swiftpay_api_client-0.1.1b0.tar.gz 22.0 kB Without provenance Details for swiftpay_api_client-0.1.1b0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for swiftpay-api-client 0.1.1b0
File Interpreter ABI Platform Actions
swiftpay_api_client-0.1.1b0-py3-none-any.whl Python 3 none any Details for swiftpay_api_client-0.1.1b0-py3-none-any.whl

Total release size: 46.3 kB

Release files / swiftpay_api_client-0.1.1b0.tar.gz

Download URL swiftpay_api_client-0.1.1b0.tar.gz
Size 22.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a3cd7e5b0d7f40c84ce3d485b1b1a95538145684d981a6c2293fdc8ba2e7545f
BLAKE2b-256 checksum
How to use checksums
3dc55fdd153cabc56de38ad4bab409bc116802da5d81155630fe8d77212eef30
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Release files / swiftpay_api_client-0.1.1b0-py3-none-any.whl

Download URL swiftpay_api_client-0.1.1b0-py3-none-any.whl
Size 24.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
749f3f0893a2a2778c6aed9ef6766c8b8c7da6954a847531e6afa4fcb75b3c4c
BLAKE2b-256 checksum
How to use checksums
a2eeb2f2b37dd1e6c17e66fc2698eee999eb8c4409fecf2a88d11559789798a8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.12

Security for swiftpay-api-client 0.1.1b0

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
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