The full upstream README, mirrored here for reference. Install config, tool schemas, adoption signals, and an original overview live on the X402 API Server listing page.
Pay-per-call crypto/DeFi data API using HTTP 402 Payment Required.
No API keys. No subscriptions. AI agents pay USDC on Base, per request.
🌐 Live at: https://x402-api.fly.dev
🤖 Agent Identity: #18763 on Base (ERC-8004)
📝 Blog Post: I Built a DeFi Data API Where AI Agents Pay Per Call
This is a DeFi/crypto data API server where payment is part of the HTTP protocol itself.
Every endpoint costs a small USDC micropayment — between 0.001 and 0.008 USDC (fractions of a cent). When a client hits a protected endpoint, the server responds with HTTP 402 Payment Required and precise payment instructions. The client pays, retries with proof, and gets data.
No accounts. No OAuth. No billing dashboard. Just: "this costs 0.003 USDC — pay here."
This model is designed for AI agents: autonomous software that needs to call APIs without a human reaching for a credit card. The agent holds a wallet, pays exactly what's needed, and moves on.
The stack:
| Endpoint | Price | Description |
|---|---|---|
GET /api/price-feed | 0.001 USDC | BTC/ETH/SOL prices + top 24h movers (live CoinGecko) |
GET /api/gas-tracker | 0.001 USDC | Multi-chain gas prices (ETH, Base, Polygon, Arbitrum) with speed tiers |
GET /api/dex-quotes | 0.002 USDC | Compare swap quotes across Uniswap, SushiSwap, 1inch |
GET /api/token-scanner | 0.003 USDC | Token security & risk analysis — rug-pull detection flags |
GET /api/whale-tracker | 0.005 USDC | Token holder concentration, Gini coefficient, whale alerts |
GET /api/yield-scanner | 0.005 USDC | Top DeFi yields across Aave, Compound, Morpho, Lido, Pendle + more |
GET /api/funding-rates | 0.008 USDC | Perp funding rates across 6 venues + arb ranking |
GET /api/wallet-profiler | 0.008 USDC | Wallet portfolio analysis, holdings, activity, risk profile |
GET /api/endpoints | Free | Machine-readable endpoint catalog |
GET /health | Free | Health check |
| Endpoint | Parameter | Example |
|---|---|---|
/api/dex-quotes | from, to, amount | ?from=ETH&to=USDC&amount=1.5 |
/api/token-scanner | token | ?token=PEPE or ?token=0x... |
/api/whale-tracker | token | ?token=ETH |
/api/yield-scanner | chain, min_tvl | ?chain=base&min_tvl=1000000 |
/api/funding-rates | asset | ?asset=BTC |
/api/wallet-profiler | address | ?address=0x... |
The x402 protocol extends the long-forgotten HTTP 402 Payment Required status code into a machine-readable micropayment standard.
Step 1 — Initial request (no payment)
Step 2 — Server returns 402
Step 3 — Client pays and retries
Step 4 — Server verifies and responds
In the current repo, the production-ready payment proof path is:
The repo also supports EIP-3009 transferWithAuthorization settlement when you configure one of these:
X402_SETTLEMENT_PRIVATE_KEY — the server submits transferWithAuthorization on-chain and pays gas.X402_FACILITATOR_URL — the server forwards the signed authorization to your facilitator.Without either of those configured, the deployment stays on the txHash payment proof path only.
Receiving wallet: 0x60264c480b67adb557efEd22Cf0e7ceA792DefB7
Network: Base mainnet (chain ID 8453)
Asset: USDC (0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913)
x402-fetch is the official client library from Coinbase that handles the payment flow automatically. Drop it in as a fetch replacement.
wrapFetchWithPayment DoestransferWithAuthorization)X-Payment headerNote: this is the standard x402 client flow. The current server repo also supports a simpler proof format where a client pays on-chain first, then sends a Base64 JSON X-Payment header like:
Your wallet needs USDC on Base mainnet. You can bridge USDC from Ethereum to Base using the Base Bridge or buy directly on Coinbase.
This API is registered as an AI agent on Base via ERC-8004 — the Ethereum standard for on-chain agent identity.
Agent ID: #18763
Registry contract: 0x8004A169FB4a3325136EB29fA0ceB6D2e539a432
Network: Base mainnet
The registration includes:
This lets discovery services, AI marketplaces, and other agents find and verify this API on-chain — no centralized registry required.
See the registration data: agent-registration.json
The MCP (Model Context Protocol) server now lives in its own standalone repo:
@x402-api/mcp-serverQuick setup:
Add to Claude Desktop (claude_desktop_config.json):
→ See the standalone MCP repo for full docs: x402-api-mcp-server README
The elizaos-plugin/ directory contains an ElizaOS plugin that gives autonomous agents natural-language access to all 8 endpoints.
Install:
Register in your ElizaOS agent:
The plugin adds 8 actions: GET_CRYPTO_PRICES, GET_GAS_PRICES, GET_DEX_QUOTES, SCAN_TOKEN, TRACK_WHALES, SCAN_YIELDS, GET_FUNDING_RATES, PROFILE_WALLET.
→ See elizaos-plugin/README.md for full docs.
In development mode (NODE_ENV=development), any non-empty X-PAYMENT header is accepted — no real payments needed for local testing.
| Variable | Default | Description |
|---|---|---|
PAY_TO_ADDRESS | 0x60264c...DefB7 | USDC receiving wallet on Base |
PORT | 4020 | Server port |
NODE_ENV | development | Set production for real payment verification |
BASE_RPC_URL | https://mainnet.base.org | Base RPC URL |
X402_SETTLEMENT_MODE | auto | auto, direct, facilitator, or disabled |
X402_SETTLEMENT_PRIVATE_KEY | none | Sponsor key for direct transferWithAuthorization settlement |
X402_FACILITATOR_URL | none | Custom facilitator URL for EIP-3009 settlement |
X402_FACILITATOR_API_KEY | none | Optional bearer token for your facilitator |
MIT