How the x402 payment flow works
Paid BotsRated lookups (GET /v1/check, GET /v1/report/{host}, GET /v1/best, and the matching MCP tools) settle in USDC on Base (eip155:8453) using x402 v2 (scheme: "exact"). You do not need an account or API key to pay via x402.
Happy path
- Your client calls a paid route without payment (or past its free daily quota, or with
X-BotsRated-Free-Quota: off). - If free daily checks or prepaid credits remain on your key, BotsRated returns
200withcharged: false(or uses 1 prepaid credit). - Otherwise, BotsRated returns HTTP 402 Payment Required with an x402 v2 challenge in both the JSON body and the
PAYMENT-REQUIREDheader (Access-Control-Expose-HeadersincludesPAYMENT-REQUIREDandPAYMENT-RESPONSE). - For
/v1/checkand/v1/best, theacceptsentry quotesamount: "10000"($0.01USDC, 6 decimals), asset0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913oneip155:8453. For/v1/report/{host}, the price is$0.01(amount: "10000"). - Your x402 client (
@x402/fetch,@x402/mcp, or Pythonbotsrated[x402]) signs the authorization and retries (HTTP payment header, or_meta["x402/payment"]on MCP). - Payment settles **only on a
2xxanswer**. Any HTTP400or above response (charged: false) is not charged.
A 402 response is normal payment negotiation, not a service outage.
Common pitfalls and rules
- Client spend caps: Make sure your client's per-payment budget covers the quoted price (for example,
@x402/fetchspendControls.maxAmountPerPayment). Plan/subscription purchases ($19or$99or$199) fail if a wallet client still has a$1cap. - 404 before 402: Uncovered hosts return
404 host_not_coveredbefore any payment challenge, and invalid hosts return400, with no charge. - Quota fallback: Nothing is served free without a successful quota check. If the quota store cannot answer in time, an unpaid call receives a
402challenge rather than an unverified free pass. - Finality: On-chain USDC payments on Base are public and final once settled. Any refund owed for BotsRated's own fault is sent as a new payment to the paying wallet (https://botsrated.com/checkout-terms §4).