# Munchausen Lab x402 Analytics API ## Service - Name: Munchausen Lab Analytics - URL: https://munchausen-x402.munlab.workers.dev - Protocol: x402 - Network: base - Payment: USDC (paid endpoints) / FREE (trial + discovery) ## Free Endpoints (no payment, no signup) - GET / — Service discovery + landing page - GET /api/demo — Free sample AI analysis (unlimited, no signup) - GET /api/free — Real-time BTC/ETH/SOL prices (5/min) - GET /api/token-safety/free?address=0x... — Basic EVM token rug-risk check (5/day per IP, no payment) - GET /health — Health check - GET /docs — API documentation - GET /agent.json — A2A agent card - GET /llms.txt — This file ## Paid Endpoints (x402 USDC payments) ### GET /api/quote - Price: 0.01 USDC - Description: Real-time market prices for BTC, ETH, SOL via Coinbase (Binance/CoinCap/CoinGecko fallbacks) - Parameters: symbol (optional, comma-separated: btc,eth,sol) - Rate limit: 10/min - Example: curl https://munchausen-x402.munlab.workers.dev/api/quote?symbol=btc,eth ### GET /api/analyze - Price: 0.05 USDC - Description: LLM-powered market analysis via OpenRouter - Rate limit: 10/min - Example: curl https://munchausen-x402.munlab.workers.dev/api/analyze ### GET /api/report - Price: 0.25 USDC - Description: Full structured research report via OpenRouter - Rate limit: 10/min - Example: curl https://munchausen-x402.munlab.workers.dev/api/report ### POST /api/scrape - Price: 0.005 USDC - Description: Fetch any URL and return clean extracted text (HTML stripped), title, metadata - Body: {"url": "https://example.com"} - Returns: {url, status, title, text (up to 20k chars), length, truncated} - Example: curl -X POST https://munchausen-x402.munlab.workers.dev/api/scrape -H 'Content-Type: application/json' -d '{"url":"https://example.com"}' ### POST /api/fact-check - Price: 0.02 USDC - Description: LLM fact-check of a claim: verdict (supported/refuted/partially_true/unverifiable), confidence 0-1, reasoning - Body: {"claim": "..."} - Example: curl -X POST https://munchausen-x402.munlab.workers.dev/api/fact-check -H 'Content-Type: application/json' -d '{"claim":"The Eiffel Tower is in London"}' ### POST /api/token-safety - Price: 0.01 USDC - Description: EVM token rug-pull risk screening: liquidity, volume, pair age, txn counts, heuristic 0-100 risk score, verdict - Body: {"address": "0x..."} - Data: DexScreener (live DEX pairs) - Example: curl -X POST https://munchausen-x402.munlab.workers.dev/api/token-safety -H 'Content-Type: application/json' -d '{"address":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"}' ## Free Endpoints - GET / — Service discovery + landing page - GET /api/demo — Free sample AI analysis (unlimited, no signup) - GET /api/free — Real-time BTC/ETH/SOL prices (5/min) - GET /api/token-safety/free?address=0x... — Basic EVM token rug-risk check (5/day per IP, no payment) - GET /health — Health check - GET /docs — API documentation ## Payment Flow 1. Send request to a paid endpoint 2. Receive HTTP 402 with payment requirements in the JSON body (accepts[] array) and PAYMENT-REQUIRED header (base64) 3. Pay USDC via EIP-3009 transferWithAuthorization on Base (USDC contract: 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913, payTo: 0x6BEd284f036B194cCfD1d035CadDAF164035e51d) 4. Retry with X-PAYMENT header (base64-encoded payment payload: {x402Version, scheme:"exact", network:"base", resource, payload:{signature,...}}) 5. Receive 200 with data; settlement proof in X-PAYMENT-RESPONSE header ## Payment Flow Example (402 -> X-PAYMENT retry) Step 1 - call without payment, get requirements: ```bash curl -i https://munchausen-x402.munlab.workers.dev/api/quote?symbol=btc # HTTP/1.1 402 Payment Required # {"x402Version":1,"accepts":[{"scheme":"exact","network":"base","maxAmountRequired":"10000","asset":"0x833589fCD...","payTo":"0x6BEd284f..."}],"error":"X-PAYMENT header is required"} ``` Step 2 - sign EIP-3009 transferWithAuthorization (10000 = $0.01, 6 decimals) and retry: ```bash curl https://munchausen-x402.munlab.workers.dev/api/quote?symbol=btc -H "X-PAYMENT: " # HTTP/1.1 200 OK # {"btc":{"price":...,"change_24h":...}, ...} # x-payment-response: ``` Client libraries that handle steps 2-4 automatically: - TypeScript: `npx x402 fetch` or @x402/fetch (fetchWithPayment) - Python: x402 package (requests with payment hooks) ## Agent Discovery - A2A agent card: GET /agent.json - OpenAPI spec: GET /openapi.json (tool generators) - MCP server (7 tools): POST https://munchausen-mcp.munlab.workers.dev/mcp (JSON-RPC 2.0, Streamable HTTP) - MCP tools/list example: curl -X POST https://munchausen-mcp.munlab.workers.dev/mcp -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' ## Data Sources - Prices: CoinGecko API (real-time, 60s cache) - Analytics: OpenRouter LLM (AI-generated)