Skip to main content

Python SDK for the Machine Payments Protocol (MPP)

Project description

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

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


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.8.2.tar.gz (148.2 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.8.2-py3-none-any.whl (87.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for pympp-0.8.2.tar.gz
Algorithm Hash digest
SHA256 be6f9eeb52f1688d934cafbb57d0cc1e2afd7dd02bbc09d38b03f21e2fb59a5c
MD5 c972c84f9bf9a5799074b04f3a1c7b5f
BLAKE2b-256 aa516cf407f24ad3e798e4730e502b65d01083dfcb69b968640544aa2ac18803

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pympp-0.8.2-py3-none-any.whl
  • Upload date:
  • Size: 87.6 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.8.2-py3-none-any.whl
Algorithm Hash digest
SHA256 df28393460ffe8f9971e89ebf43e40e452c1dc648aba2fe86fa355c3858e7256
MD5 c47cc341fa58b426728785fb386bda9b
BLAKE2b-256 05a69ed89bb93d80b79963e243e1bcf7831e3d92eeaf467cf904ec22493a6c8f

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