Skip to main content

pympp

Python SDK for the Machine Payments Protocol

PyPI License

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")

Custom transports can reuse method matching and credential creation without depending on HTTPX:

from mpp.client import PaymentTransport
from mpp.runtime import PaymentRuntime

payments = PaymentRuntime([method])
challenge, method = payments.match_challenge(challenges)
credential = await payments.create_credential(challenge, method)

transport = PaymentTransport(runtime=payments)

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

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.10.1.tar.gz (171.8 kB view details)

Uploaded Source

Built Distribution

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

pympp-0.10.1-py3-none-any.whl (95.3 kB view details)

Uploaded Python 3

File details

Details for the file pympp-0.10.1.tar.gz.

File metadata

  • Download URL: pympp-0.10.1.tar.gz
  • Upload date:
  • Size: 171.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for pympp-0.10.1.tar.gz
Algorithm Hash digest
SHA256 846ffee1cbf9109fef89694a7e3073e9f2114bed094d481ab3a93a108526dfe8
MD5 004ca53c0f8ebfdb954668c9426b4377
BLAKE2b-256 68712bcb7701570dcdeb779bf072af009a899206fc7c6dfc238b40f82bbf49d1

See more details on using hashes here.

File details

Details for the file pympp-0.10.1-py3-none-any.whl.

File metadata

  • Download URL: pympp-0.10.1-py3-none-any.whl
  • Upload date:
  • Size: 95.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for pympp-0.10.1-py3-none-any.whl
Algorithm Hash digest
SHA256 878067e70dfa7509e0ce783c1f2e0ec5bfc279f84cb2fed030f2f3d0bf6faaf1
MD5 af9ba08341b22bf7fbd47261d6d93901
BLAKE2b-256 0e469adfc30b97e1851ce60ca333ec18a7481f78d2c7a661b2b30ac55979e2fc

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