Python SDK for the Machine Payments Protocol (MPP)
Project description
pympp
Python SDK for the Machine Payments Protocol
Documentation
Full documentation, API reference, and guides are available at mpp.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()},
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://mpp.dev/api/ping/paid")
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.5.0.tar.gz
(111.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.5.0-py3-none-any.whl
(68.1 kB
view details)
File details
Details for the file pympp-0.5.0.tar.gz.
File metadata
- Download URL: pympp-0.5.0.tar.gz
- Upload date:
- Size: 111.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f84f259ec3d2435186f744762326e698c700b4365e7f54b516cb9aeda417faf2
|
|
| MD5 |
91379e85a6c7535af68ccba5c71106de
|
|
| BLAKE2b-256 |
b42ba5aac8841e1d2e740e8e9db26d2434a28e3e20fca83d450fc42fc58fc18b
|
File details
Details for the file pympp-0.5.0-py3-none-any.whl.
File metadata
- Download URL: pympp-0.5.0-py3-none-any.whl
- Upload date:
- Size: 68.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9cfdc799bc28add8ab7c94ed1c44bd0d64bcafc122ec2064b0f99f56982bd5c1
|
|
| MD5 |
f0bb88b65facc969f85ba9bba8cb9cdc
|
|
| BLAKE2b-256 |
494bdfaf666131f7d7d9d869cc863e61167886b2a700b30478659369184d0d3a
|