Accept Crypto in Python, FastAPI & Django

Monetize Python backends, FastAPI LLM inference endpoints, Django SaaS apps, and autonomous AI agents with XPayr REST API v1, async httpx sessions, HMAC-SHA256 webhooks, and HTTP 402 paywalls.

Integration Details

Version 1.0.0
Last Updated 2026-11-11
Compatibility Python 3.10+ Β· FastAPI Β· Django Β· Flask
Open-Source Repo v1.0.0 Release
View Python Examples

How to integrate XPayr in FastAPI or Django

  1. Generate your sk_test_ API key and Webhook Secret in XPayr Merchant Dashboard
  2. Call POST https://xpayr.com/api/v1/payments using httpx.AsyncClient or requests
  3. Verify X-XPayr-Signature with Python hmac.compare_digest(expected, received)
  4. Optional: Add HTTP 402 Payment Required FastAPI middleware (/x402) for AI agents

5-Step FastAPI / Django Setup

  1. Store XPAYR_API_KEY and XPAYR_WEBHOOK_SECRET in Pydantic Settings or Django settings.py.
  2. Create an async checkout endpoint posting amount, currency, network, and user metadata to /api/v1/payments.
  3. Expose a POST /webhooks/xpayr route reading await request.body() raw bytes.
  4. Compute hmac.new(secret.encode(), raw_body, hashlib.sha256).hexdigest() and verify with hmac.compare_digest.
  5. For LLM/API monetization, return status_code=402 challenges verifiable via /.well-known/jwks.json.

Why Python & AI engineering teams choose XPayr

Async FastAPI native fit

Clean OpenAPI 3.1.0 JSON endpoints pair effortlessly with Pydantic v2 and httpx.AsyncClient.

HTTP 402 AI monetization

Charge per GPU job, RAG query, or dataset call with sub-millisecond ES256 JWKS verification (/x402).

LangChain & MCP ready

Connect Python AI agents directly to POST https://xpayr.com/api/mcp with spend guardrails.

Zero chargebacks on GPUs

Stop losing H100/A100 compute hours to stolen credit cards β€” settle 99.5% in USDC/USDT.

Purpose-Built for the Python AI, Data & Fintech Ecosystem

Python and FastAPI sit at the heart of modern AI inference clouds, quantitative analytics platforms, Telegram aiogram bots, and Django SaaS products. XPayr gives Python engineers clean REST API v1 primitives, OpenAPI 3.1 schemas (api-docs.xpayr.com), HTTP 402 machine paywalls, and non-custodial multi-chain settlement at 0.5%.

FAQ

Python, FastAPI & Django Integration FAQ

Yes. Download https://xpayr.com/.well-known/openapi.json and generate typed Pydantic/httpx clients via openapi-python-client in seconds.

Read raw bytes (await request.body() in FastAPI or request.body in Django) and compare HMAC-SHA256 digests using hmac.compare_digest β€” copy ready snippets from /tools/webhook-tester.

Yes. Point any MCP-compatible Python client to npx -y @xpayr/mcp-server or POST https://xpayr.com/api/mcp.

Yes. Pass account_id in payment session metadata and credit your Postgres/Redis token ledger idempotently (/player-deposits).

Monetize FastAPI, Django & AI APIs at 0.5%.

Copy verified Python webhook & session snippets from /sdks and /tools/webhook-tester.