Skip to main content

Prequisites

  • HTTPayer API Key (for Proxy mode) or Private Key (for Relay mode)
  • If using Proxy mode:
    • Account funded with credits for payments
  • If using Relay mode:
    • USDC on a supported chain for payments (defaults to USDC on Base for EVM private key, USDC on Solana for Solana private key)

Proxy Mode (Simplest)

Use your HTTPayer API key for account-based payments.
from httpayer import HTTPayerClient

# Initialize with API key from environment
client = HTTPayerClient()

# Make a request - automatically handles 402 payments
response = client.request("GET", "https://api.example.com/protected")

print(response.status_code)  # 200
print(response.json())       # API data

Relay Mode (Self-Custodial)

Use your own wallet for self-custodial payments.

EVM Wallet

import os
from httpayer import HTTPayerClient

client = HTTPayerClient(
    private_key=os.getenv("EVM_PRIVATE_KEY")
)

response = client.request("GET", "https://api.example.com/protected")
print(response.json())

Solana Wallet

import os
from httpayer import HTTPayerClient

client = HTTPayerClient(
    private_key=os.getenv("SOLANA_PRIVATE_KEY")
)

response = client.request("GET", "https://api.example.com/protected")
print(response.json())

Simulate Before Paying

Preview payment costs without executing:
# Dry-run simulation
sim = client.request("GET", "https://api.example.com/protected", simulate=True)
print(sim.json())  # Shows payment requirements

# Execute actual payment
response = client.request("GET", "https://api.example.com/protected")
print(response.json())  # Actual data

Next Steps