x402 in 5 minutes
Pay for any API call with USDC, no signup, no API keys
What is x402? It revives the dormant
HTTP 402 Payment Required status code. A server
returns 402 with machine-readable payment terms; your client pays a few cents of USDC on-chain and retries. No account,
no key, no invoice, no human. It is how autonomous agents buy data and compute.1 · The flow
Client --GET /resource--> Server Client <--402 + terms---- Server (price, token, address, network) Client --pay USDC on Base + retry with X-PAYMENT header--> Server Client <--200 + data------ Server
2 · Call your first paid API (JavaScript)
npm i x402-fetch viem
import { wrapFetchWithPayment } from "x402-fetch";
import { createWalletClient, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { base } from "viem/chains";
const account = privateKeyToAccount(process.env.PRIVATE_KEY); // a wallet with a little USDC on Base
const wallet = createWalletClient({ account, chain: base, transport: http() });
const pay = wrapFetchWithPayment(fetch, wallet);
const res = await pay("https://x402.tavily.com/search?query=x402", { method: "GET" });
console.log(await res.json()); // paid, retried, done
3 · Fund a wallet
Create any EVM wallet, hold a few dollars of USDC on Base for the calls and a little ETH on Base for gas (often sponsored). Most services cost $0.001 – $0.01 per call, so a few dollars goes a long way.
4 · Find a service
Browse the catalog and open any service for ready-to-run JavaScript, Python and curl. Every page is generated from the live on-chain registry.
Building an x402 service yourself? List it on the Coinbase Bazaar and it shows up here automatically.
ad slot · a crypto-native, no-tracking ad loads here in production
Query this registry programmatically. Every service here is searchable through the
x402hub API, an x402-payable endpoint your agents call and pay per request in USDC.
https://api-service-sandy.vercel.app · GET /api/search?q=... · $0.002 / call
Prefer to just support the project? Tip USDC on Base to
0x40BbeB1BEd1D4ba6f1d4C0eE0C9D93e2dA3347C6. This hub is free and ad-light.