Pay per request with USDC on Base. No subscription, no signup — just a crypto wallet.
x402 is an open HTTP payment protocol that lets API clients pay for individual requests using USDC on Base (Ethereum L2).
When your free tier runs out, instead of signing up for a subscription you can pay $0.002 per scrape directly
from your wallet — no account required. The server returns an HTTP 402 with cryptographic payment requirements, your wallet signs
and submits the payment on-chain, and you resend the request with an X-PAYMENT header.
The x402 client library handles all of this automatically.
If you're building with Coinbase AgentKit, x402 is handled automatically.
npm install @coinbase/agentkit
Your agent needs a small amount of USDC on Base mainnet (a few cents is enough to start).
AgentKit intercepts 402 responses, pays, and retries. No code changes needed beyond initializing AgentKit with your wallet.
The x402 npm package wraps the standard fetch function to automatically handle 402 payment challenges.
npm install x402 @coinbase/agentkit viem
Fund it with USDC on Base. Each scrape costs $0.002 USDC.
wrapFetch(fetch, wallet) — the library handles payment automatically when you hit a 402.
import { wrapFetch } from 'x402/client';
import { createWallet } from '@coinbase/agentkit';
// Create and fund a Coinbase wallet (USDC on Base)
const wallet = await createWallet();
const fetch402 = wrapFetch(fetch, wallet);
// This automatically handles 402 payment challenges
const response = await fetch402('https://anybrowse.dev/scrape', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ url: 'https://example.com' })
});
const { markdown } = await response.json();
console.log(markdown);
from x402.client import wrap_httpx
import httpx
# wallet must be a Coinbase CDP wallet or compatible signer
client = wrap_httpx(httpx.Client(), wallet)
response = client.post(
'https://anybrowse.dev/scrape',
json={'url': 'https://example.com'}
)
data = response.json()
print(data['markdown'])
import { wrapFetch } from 'x402/client';
import { createWalletClient, http } from 'viem';
import { base } from 'viem/chains';
import { privateKeyToAccount } from 'viem/accounts';
const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`);
const walletClient = createWalletClient({
account,
chain: base,
transport: http()
});
const fetch402 = wrapFetch(fetch, walletClient);
// Crawl example — $0.01 per call
const response = await fetch402('https://anybrowse.dev/crawl', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ query: 'best web scraping tools 2025', limit: 5 })
});
const { results } = await response.json();
Payments are USDC on Base (mainnet). The x402 protocol uses the Coinbase facilitator. Gas is minimal — Base fees are fractions of a cent.
For high-volume use, compare: Pro subscription at $4.99/month gives 10,000 scrapes (≈$0.0005/call).
0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913)0x8D76E8FB38541d70dF74b14660c39b4c5d737088| Error | Cause | Fix |
|---|---|---|
| paymentPayload is invalid | Manually constructed X-PAYMENT header with wrong format or encoding | Use the x402 npm package or Coinbase AgentKit. Do not manually construct the header. |
| Invalid X-PAYMENT header — expected base64 JSON | X-PAYMENT value is not valid base64 or not valid JSON when decoded | The header must be a base64-encoded JSON object. Always use the x402 client library to generate it. |
| Payment already used | Replay attack — same payment submitted twice | Each payment is single-use. The x402 library generates a fresh payment per request automatically. |
| Payment verification error — try again | Temporary facilitator error | Retry the request. If persistent, check Base network status. |
| Insufficient funds | Wallet USDC balance is too low | Fund your wallet with USDC on Base mainnet. A few cents is enough for many requests. |
| Daily free limit reached | 50 free scrapes/day per IP exhausted | Use x402 micropayments (this guide), subscribe to Pro ($4.99/month), or use the MCP endpoint (unlimited for agents). |
The most frequent error is attempting to manually construct the X-PAYMENT header. This requires EIP-712 signing, USDC permit2 encoding, and specific JSON structure — it's complex and error-prone. Always use the x402 client library.
// Wrong — do not manually set X-PAYMENT
headers['X-PAYMENT'] = btoa(JSON.stringify({ amount: '2000', to: '0x...' }));
import { wrapFetch } from 'x402/client';
// wrapFetch handles all payment signing and header construction
const fetch402 = wrapFetch(fetch, wallet);
const response = await fetch402('https://anybrowse.dev/scrape', { ... });