Skip to main content

Introduction

The HTTPayer Python SDK provides a simple interface for accessing 402-protected APIs using either proxy mode (API key) or relay mode (private key).

Installation

pip install httpayer

Quick Start

Proxy Mode

from httpayer import HTTPayerClient

client = HTTPayerClient()  # Uses HTTPAYER_API_KEY from environment
response = client.request("GET", "https://api.example.com/protected")
print(response.json())

Relay Mode

import os
from httpayer import HTTPayerClient

client = HTTPayerClient(
    private_key=os.getenv("EVM_PRIVATE_KEY"),
    network="base"
)
response = client.request("GET", "https://api.example.com/protected")
print(response.json())

Key Features

  • Dual Access Patterns: Proxy (API key) or Relay (private key)
  • Auto-handles 402: Automatically processes payment flows
  • Cross-chain Support: Pay on one chain, access APIs on another
  • Privacy Mode: Route payments through HTTPayer relay
  • Simulation: Preview costs without executing payments

Next Steps