x402-api — pay-per-call DeFi data — x402 protocol v1
Pay-per-call DeFi & crypto data API · for AI agents · No API keys. No subscriptions. Just USDC on Base.
ONLINE
NETWORK Base (8453)
ASSET USDC
ENDPOINTS 8 LIVE
PROTOCOL x402 + EIP-3009
ERC-8004 AGENT #18763
BTC $── ── ETH $── ── SOL $── ── SUI $── ── HYPE$── ── LINK$── ── BTC $── ── ETH $── ── SOL $── ── SUI $── ── HYPE$── ── LINK$── ──
Agent Identity — ERC-8004
ERC-8004 Agent ID
#18763
Registry: base:0x8004A169FB4a3325136EB29fA0ceB6D2e539a432
View on BaseScan ↗
Payment Address (USDC on Base)
0x60264c480b67adb557efEd22Cf0e7ceA792DefB7
View on BaseScan ↗ · USDC contract: 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
Domain Verification
/.well-known/agent-registration.json
ERC-8004 · Trust model: reputation
View agent-registration.json ↗
Server Endpoint
https://x402-api.fly.dev
8 pay-gated endpoints · x402 protocol
Payment: configured EIP-3009 settlement · legacy txHash opt-in
How x402 Works
01
Request
Agent calls endpoint — no payment header yet
→
02
402 Response
Server returns payTo address, asset, amount required
→
03
Sign & Pay
Agent pays on-chain or signs EIP-3009 transferWithAuthorization
→
04
Retry
Agent retries with X-Payment: <base64 payload>
→
05
Verify + Serve
Server verifies and settles payment → 200 OK + data
Available Endpoints
Method Endpoint Price Description Data
GET /api/price-feed 0.001 USDC BTC, ETH, SOL prices + top 5 movers/losers by 24h change. 60s server cache. LIVE ✓
GET /api/gas-tracker 0.001 USDC Gas prices on Ethereum, Base, Polygon, Arbitrum — slow/normal/fast tiers + USD cost estimates. LIVE ✓
GET /api/dex-quotes 0.002 USDC One live ParaSwap aggregate route. No independent venue comparison. ?from=ETH&to=USDC&amount=1 LIVE ✓
GET /api/token-scanner 0.003 USDC GoPlus ERC-20 flags and a disclosed heuristic score; missing fields are null. ?token=PEPE LIVE ✓
GET /api/whale-tracker 0.005 USDC GoPlus top-holder sample and reported supply share. Full distribution and transfers unavailable. ?token=ETH LIVE ✓
GET /api/yield-scanner 0.005 USDC DefiLlama pool APYs and TVL. Filter by chain, asset, TVL; no safety rating. LIVE ✓
GET /api/funding-rates 0.008 USDC Hyperliquid and dYdX hourly rates with indicative spreads; fees and basis risk excluded. LIVE ✓
GET /api/wallet-profiler 0.008 USDC Blockscout priced wallet balances or limited public RPC fallback; partial coverage disclosed. ?address=0x… LIVE ✓
GET /health FREE Server health check · returns status, uptime, pay-to address FREE
Live Preview — /api/price-feed
BTC Loading… ─
ETH Loading… ─
SOL Loading… ─
Integration — Base USDC clients

Use the included MCP client for Base USDC EIP-3009 payment with a 0.01 USDC default per-call cap. This server uses a JSON x402 v1 challenge; check other SDK versions before mainnet use.

MCP · Base USDC EIP-3009
# Install the MCP client and signing dependency
npm install -g @x402-api/mcp-server viem

# Set a dedicated Base wallet key with USDC
export X402_WALLET_PRIVATE_KEY=0xYOUR_PRIVATE_KEY

# Start MCP; default payment cap is 0.01 USDC per call
x402-api-mcp

# In your MCP-capable agent, call get_crypto_prices, scan_yields, etc.
# The API must advertise EIP-3009 settlement.
Shell — Manual 402 flow
# Step 1: Probe — get payment requirements (returns 402)
curl -s https://x402-api.fly.dev/api/price-feed | jq .

# Response: 402 Payment Required
{
  "x402Version": 1,
  "error": "Payment Required",
  "accepts": [{
    "scheme": "exact",
    "network": "base",
    "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    "payTo": "0x60264c480b67adb557efEd22Cf0e7ceA792DefB7",
    "maxAmountRequired": "1000"
  }]
}

# Step 2: Pay on-chain or sign EIP-3009 transferWithAuthorization
# use a compatible client; do not submit raw txHash unless legacy proof is enabled

# Step 3: Retry with X-Payment header (base64 JSON payload)
curl -s https://x402-api.fly.dev/api/price-feed \
  -H "X-Payment: <base64-encoded-payment-payload>" | jq .data.core

# Response: 200 OK — live crypto prices
[
  { "id": "bitcoin",  "price_usd": 98000, "change_24h_pct": 2.1  },
  { "id": "ethereum", "price_usd": 2750,  "change_24h_pct": -0.8 },
  { "id": "solana",   "price_usd": 185,   "change_24h_pct": 4.2  }
]
TypeScript · Two paid reads
import { x402ApiRequest } from '@x402-api/elizaos-plugin';

const config = { walletPrivateKey: process.env.X402_WALLET_PRIVATE_KEY };
const funding = await x402ApiRequest<{
  arb_opportunities: Array<{ spread_bps: number }>
}>('/api/funding-rates', { asset: 'ETH' }, config);
const gas = await x402ApiRequest<{
  data: Record<string, { gas_price_gwei: { normal: number | null } }>
}>('/api/gas-tracker', {}, config);

console.log('Indicative spread:', funding.arb_opportunities[0]?.spread_bps ?? 'none');
console.log('Arbitrum gas:', gas.data.arbitrum?.gas_price_gwei.normal ?? 'unavailable');
// Fees and basis risk are excluded. Total API charge: 0.009 USDC.
Request / Response Flow
Step 1 — Initial Request (→ 402)
GET /api/price-feed HTTP/1.1
Host: x402-api.fly.dev
Response 402 Payment Required
{
  "x402Version": 1,
  "error": "Payment Required",
  "accepts": [{
    "scheme": "exact",
    "network": "base",
    "asset": "0x833589fC...",
    "payTo": "0x60264c48...",
    "maxAmountRequired": "1000",
    "extra": { "chainId": 8453 }
  }]
}
Step 2 — With Payment (→ 200)
GET /api/price-feed HTTP/1.1
X-Payment: eyJ4NDAyVmVyc2lvbiI6MSwidHlwZSI6...
Response 200 OK
{
  "timestamp": "2026-02-22T09:35:00Z",
  "source": "CoinGecko",
  "payment": {
    "verified": true,
    "amount": "1000"
  },
  "data": {
    "core": [
      { "id": "bitcoin",
        "price_usd": 98000,
        "change_24h_pct": 2.1 }
    ]
  }
}
Explore 3 runnable workflows →