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 |
Protocol
Built on the "Payment" HTTP Authentication Scheme. See mpp-specs 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
pympp-0.2.0.tar.gz
(78.4 kB
view details)
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
pympp-0.2.0-py3-none-any.whl
(57.0 kB
view details)
File details
Details for the file pympp-0.2.0.tar.gz.
File metadata
- Download URL: pympp-0.2.0.tar.gz
- Upload date:
- Size: 78.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c69862b4b1a69ae278b626214e0ac73f391bb655c741b1d98c5bdcca53ca95b7
|
|
| MD5 |
42db0c85e3829715a565be15f41eaf95
|
|
| BLAKE2b-256 |
32af642f6d4ec810a2e89d1b15e88533d870008a345d0f5164533671482448d6
|
File details
Details for the file pympp-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pympp-0.2.0-py3-none-any.whl
- Upload date:
- Size: 57.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31edeaae866c477fb44dd8e16c2298b67c10b15c8fcff15a8825d0ec90208d78
|
|
| MD5 |
541613801f115d6cff8ba6165f64ac7d
|
|
| BLAKE2b-256 |
33692fd9552964dc5a3ad915935b01cdb9a1b1da3a3ce7851a989bf0df8a6489
|