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.1.0.tar.gz
(27.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file x402_bazaar-1.1.0.tar.gz.
File metadata
- Download URL: x402_bazaar-1.1.0.tar.gz
- Upload date:
- Size: 27.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f61a007ae8ba1a40db291b5785e73f6e362720e3c350b34708c57093e97f880a
|
|
| MD5 |
bb1d19cdc4f36dc2b9fcff78f20a3dd2
|
|
| BLAKE2b-256 |
8888b3c7a01661731f25079115b1e52d5ab75ce4e65a1312e06fd6085dcf0a01
|
File details
Details for the file x402_bazaar-1.1.0-py3-none-any.whl.
File metadata
- Download URL: x402_bazaar-1.1.0-py3-none-any.whl
- Upload date:
- Size: 23.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f099c9d0c67ec38b9d5d863da17dabe809ff9d89f860087a6883f85f146fdb5
|
|
| MD5 |
624bd9b03a06f6eb359aa41d050d32ce
|
|
| BLAKE2b-256 |
d389a6b3d32a1226bffd721b153ff6a53cc17e9d3cce062f95ac5ddeb6dc85e5
|