HTTP 402 Payment Authentication for Python
Project description
pympp
Python SDK for the Machine Payments Protocol
Documentation
Full documentation, API reference, and guides are available at machinepayments.dev/sdk/python.
Install
pip install pympp
Quick Start
Server
from mpp import Credential, Receipt
from mpp.server import Mpp
from mpp.methods.tempo import tempo, ChargeIntent
server = Mpp.create(
method=tempo(
intents={"charge": ChargeIntent()},
currency="0x20c0000000000000000000000000000000000000",
recipient="0x742d35Cc6634c0532925a3b844bC9e7595F8fE00",
),
)
@app.get("/paid")
@server.pay(amount="0.50")
async def handler(request, credential: Credential, receipt: Receipt):
return {"data": "...", "payer": credential.source}
Client
from mpp.client import Client
from mpp.methods.tempo import tempo, TempoAccount, ChargeIntent
account = TempoAccount.from_key("0x...")
async with Client(methods=[tempo(account=account, intents={"charge": ChargeIntent()})]) as client:
response = await client.get("https://api.example.com/resource")
Examples
| Example | Description |
|---|---|
| api-server | Payment-gated API server |
| fetch | CLI tool for fetching URLs with automatic payment handling |
| mcp-server | MCP server with payment-protected tools |
Development
Always run formatting and lint checks before committing:
uv run ruff format .
uv run ruff check .
uv run python -m pytest tests/ -x -q
Protocol
Built on the "Payment" HTTP Authentication Scheme. See payment-auth-spec for the full specification.
License
MIT OR Apache-2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pympp-0.1.0.tar.gz.
File metadata
- Download URL: pympp-0.1.0.tar.gz
- Upload date:
- Size: 64.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43d2920e413b908a8e3649c710428a02a81ac2d5ab47923fea52cc0b968d76f5
|
|
| MD5 |
17403ec574ecfdd6fa90b1aac06d375b
|
|
| BLAKE2b-256 |
244093df7d2f17001a590c04a3bf5b3b3b6f00653805d0548653fd8f9154b526
|
File details
Details for the file pympp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pympp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 53.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3c8af25274176dd9f31be84a6cc5c741a90c5a4a1fbe25371adf81f2d16858e9
|
|
| MD5 |
d47697f26aa0e58a9cfee1f472c3a5f1
|
|
| BLAKE2b-256 |
6216b50299d13cadd6f9a9ace5db8e14ab19aadde98f3b77f02874eec2a8e441
|