Skip to main content

x402 payment middleware for FastAPI — powered by the SwiftPay API

Project description

swiftpay-x402-fastapi-guard

x402 payment middleware for FastAPI — powered by the SwiftPay API.

Installation

pip install swiftpay-x402-fastapi-guard

Quick start

from fastapi import FastAPI
from swiftpay import AsyncSwiftPay
from swiftpay_x402_fastapi_guard import X402Guard

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

app = FastAPI()
app.add_middleware(
    X402Guard,
    client=client,
    routes={"/v1/analyze": "https://api.example.com/v1/analyze"},
)

@app.get("/v1/analyze")
async def analyze():
    return {"sentiment": "positive", "score": 0.87}

Routes not listed in routes pass through unaffected.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

swiftpay_x402_fastapi_guard-0.1.1b0.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file swiftpay_x402_fastapi_guard-0.1.1b0.tar.gz.

File metadata

File hashes

Hashes for swiftpay_x402_fastapi_guard-0.1.1b0.tar.gz
Algorithm Hash digest
SHA256 b69df70046c89f61b7db72a3022ea5823b9cffd20036209c72b8b5e1a63354f3
MD5 ceb88e4d28d9b60efab472e4bb3391a3
BLAKE2b-256 54e1226ad1e4f2e19d5b3c97abebeec8a3cd67dd5155bc826fb11f50610a944d

See more details on using hashes here.

File details

Details for the file swiftpay_x402_fastapi_guard-0.1.1b0-py3-none-any.whl.

File metadata

File hashes

Hashes for swiftpay_x402_fastapi_guard-0.1.1b0-py3-none-any.whl
Algorithm Hash digest
SHA256 43feb564be382b39c71a0bf887dc83bca315468484075fa6b0658845eab68e52
MD5 30e0d5f111de18be1df9a204f06873d1
BLAKE2b-256 bcf11aedff135c6dff4abbaa5700018f649ff19850bd988448c967130f5cd4d8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page