The official Python SDK for the PayNode Protocol. PayNode allows autonomous AI Agents to seamlessly pay for APIs and computational resources using USDC on Base L2, utilizing the standardized HTTP 402 protocol.
For complete installation guides, advanced usage, API references, and architecture details, please visit our official documentation: 👉 docs.paynode.dev
pip install paynode-sdk-python web3from paynode_sdk import PayNodeAgentClient
agent = PayNodeAgentClient(
private_key="YOUR_AGENT_PRIVATE_KEY",
rpc_urls=["https://mainnet.base.org", "https://rpc.ankr.com/base"]
)
# Automatically handles the 402 challenge, executes the Base L2 transaction, and gets the data.
response = agent.request_gate("https://api.merchant.com/premium-data", method="POST", json={"agent": "PythonAgent"})
print(response.json())The SDK includes a complete Merchant/Agent demo in the examples/ directory.
Copy the example environment file and fill in your keys:
cp .env.example .env
# Edit .env with your private key and RPC URLsIf you're testing on Sepolia, run the helper script to mint 1,000 mock USDC:
python examples/mint_test_tokens.pypython examples/fastapi_server.pyIn another terminal:
python examples/agent_client.pyThe demo will perform a full loop: 402 Handshake -> On-chain Payment -> 200 Verification.
To publish a new version of the SDK:
- Install build tools:
pip install build twine
- Build the package:
python -m build
- Upload to PyPI:
python -m twine upload dist/*
Built for the Autonomous AI Economy by PayNodeLabs.