The x402 Python SDK implements the x402 Payment Protocol, enabling micropayments for HTTP resources. Version 2.9.0 supports Python 3.10+ and provides client and server utilities. Active development under the x402-foundation.
pip install x402No compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Initialize the x402 client and make a paywalled GET request. The private key is read from environment variable; leave empty for demo.
Always pass `private_key` to `Client()` or set `X402_PRIVATE_KEY` environment variable.
Replace `from x402.payment import PaymentRequest` with `from x402.client import prepare_payment`.
Ensure the private key is in PEM format, e.g., read from file like `open('key.pem').read()`.Call `client.get(url)` instead of `client.make_payment('GET', url)`.