Skip to main content

HTTP 402 Payment Authentication for Python

Project description

pympp

Python SDK for the Machine Payments Protocol

PyPI License

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


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.1.5.tar.gz (69.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.1.5-py3-none-any.whl (55.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pympp-0.1.5.tar.gz
  • Upload date:
  • Size: 69.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for pympp-0.1.5.tar.gz
Algorithm Hash digest
SHA256 d0dd1cd28207bd2502df801eedad73980c62faeecc67e63ea6ade3636a03c931
MD5 2b7e60cc18be3443eb8118aa0c0019b7
BLAKE2b-256 b7cd0b146a320020de4795d7b995b1106340e683ee75ff8c55898a7213c1f2b5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pympp-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 55.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for pympp-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 206621d1421b9750d653f739b72bdf02ae6651df24644bcc5aa65dbdd73b3ba8
MD5 960c6d29563731183c9855bd59578fe0
BLAKE2b-256 691265ee9e35554a6e7bb57296f61c64160caef1ab4eabaeb59f66a71bf19397

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