Skip to main content

Python SDK for x402 Bazaar — autonomous API marketplace with auto-payment

Project description

x402-bazaar

Python SDK for x402 Bazaar — the autonomous API marketplace with automatic USDC payments.

Quick Start

pip install x402-bazaar
from x402_bazaar import X402Client

# Zero-config: auto-generates wallet on SKALE (gas-free)
client = X402Client()

# Search for APIs
results = client.search("weather")

# Call with auto-payment (402 detection + USDC payment + retry)
data = client.call("weather-api", params={"city": "Paris"})
print(data.data)

Features

  • Auto-payment — transparent HTTP 402 handling (detect, pay, retry)
  • Multi-chain — Base, Polygon, SKALE (gas-free)
  • Wallet management — auto-generate, import, AES-256-GCM encryption
  • Budget control — daily/weekly/monthly spending limits
  • Async support — native async/await with httpx
  • Type-safe — full type hints, Pydantic models, py.typed
  • AI integrations — LangChain and CrewAI tools out-of-the-box

Configuration

from x402_bazaar import X402Client

# Explicit wallet + chain
client = X402Client(
    private_key="0x...",
    chain="base",  # or "polygon", "skale"
    budget={"max": 5.0, "period": "daily"},
)

# From encrypted wallet
client = X402Client.from_encrypted("wallet.json", password="secret")

Async Usage

async with X402Client(private_key="0x...") as client:
    results = await client.search_async("jokes")
    data = await client.call_async("joke-api")

LangChain Integration

pip install x402-bazaar[langchain]
from x402_bazaar import X402Client
from x402_bazaar.integrations.langchain import X402SearchTool, X402CallTool

client = X402Client()
tools = [X402SearchTool(client=client), X402CallTool(client=client)]

# Use with any LangChain agent
from langchain.agents import initialize_agent
agent = initialize_agent(tools=tools, llm=llm)
agent.run("Find a joke API and get me a joke")

CrewAI Integration

pip install x402-bazaar[crewai]
from x402_bazaar import X402Client
from x402_bazaar.integrations.crewai import X402SearchTool, X402CallTool

client = X402Client()
agent = Agent(
    tools=[X402SearchTool(client=client), X402CallTool(client=client)],
    goal="Research data using paid APIs"
)

Balance & Budget

# Check USDC balance on all chains
balances = client.get_balance()
# {"base": 12.5, "polygon": 3.0, "skale": 5.0}

# Set spending limits
client.set_budget(max_daily=5.0)

# Check budget status
status = client.get_budget_status()
print(f"Spent: ${status.spent}, Remaining: ${status.remaining}")

Supported Chains

Chain Gas Cost Speed
SKALE Free (CREDITS) ~1s
Base ~$0.001 ETH ~2s
Polygon ~$0.001 POL ~3s

License

MIT

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

x402_bazaar-1.0.0.tar.gz (23.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

x402_bazaar-1.0.0-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

Details for the file x402_bazaar-1.0.0.tar.gz.

File metadata

  • Download URL: x402_bazaar-1.0.0.tar.gz
  • Upload date:
  • Size: 23.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for x402_bazaar-1.0.0.tar.gz
Algorithm Hash digest
SHA256 3e55611c27cada844967f0f368c10933a0d50f6c4da9d53d4bda777078cc2281
MD5 be3f6e99b1e995d7c2c436e0d5ad3984
BLAKE2b-256 b1d927395063d60572c2b9ba119de75c030ceaaa9e634aebeb60b13398468095

See more details on using hashes here.

File details

Details for the file x402_bazaar-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: x402_bazaar-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 22.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.4

File hashes

Hashes for x402_bazaar-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dfd190dc0fcb87521b00f6779d4d842a37ec9103ddf7f785df380127ca96e194
MD5 be9f3a1f991b037975afb142f641ec93
BLAKE2b-256 ff4ec839c7134960337b534a970f74da79c5073776b2c4db6843e6b6ab51628b

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