DEV Community

artespraticas
artespraticas

Posted on

I built a pay-per-use web scraping API using x402 — here's how it works

I'm a graphic designer. Not a developer.

AI has been eating into my design work, so instead
of fighting it, I decided to learn how to build
AI-native tools. This is my story of building my
first pay-per-use API using x402 — the new HTTP
payment standard from Coinbase.

What is x402?

x402 revives the long-forgotten HTTP 402 "Payment
Required" status code. Instead of subscriptions or
API keys, clients pay per request using USDC on Base.

The flow is simple:

  1. Client calls your endpoint
  2. Server returns 402 with payment instructions
  3. Client pays $0.01 USDC on Base
  4. Client retries with payment proof
  5. Server returns the data

No accounts. No API keys. No subscriptions.

What I built

Scrape Agent — a pay-per-use web scraping API.

Send any URL, pay $0.01 USDC, get back clean text,
links, or HTML from that page.

Endpoint: https://scrapeagent.xyz/api/scrape/x402
Method: POST
Price: $0.01 USDC on Base

How to try it

Install agentcash (an x402 client):

npx agentcash fetch https://scrapeagent.xyz/api/scrape/x402 \
-m POST \
-b '{"url":"https://example.com","extract":"text"}'

You'll need a tiny amount of USDC on Base in your
agentcash wallet. The payment happens automatically.

The response you get back

{
"protocol": "x402",
"version": 2,
"priceUSD": "0.01",
"url": "https://example.com",
"status": "ok",
"title": "Example Domain",
"content": "This domain is for use in...",
"wordCount": 42,
"elapsed": 312
}

The tech stack

  • Vercel Edge Functions (serverless, fast)
  • x402 v2 protocol
  • USDC on Base mainnet
  • Zod for request validation
  • Zero dependencies for scraping (pure fetch + regex)

What I learned

Building this as a non-developer was challenging but
completely possible with AI assistance. The x402
protocol is surprisingly elegant — the hardest part
was getting the exact response format right.

The biggest insight: AI agents need data. Web
scraping is one of the most fundamental things any
agent needs to do. Pay-per-use makes perfect sense
for this use case — why pay a monthly subscription
when you only scrape occasionally?

What's next

I'm planning to build more agents:

  • Image alt-text generator ($0.02/image)
  • Brand color palette extractor ($0.02/scan)
  • Design feedback API ($0.25/critique)

If you're a developer interested in the x402
ecosystem, check out x402.org to learn more.

And if you want to try my scraping agent:
https://scrapeagent.xyz

Would love feedback from the developer community —
especially on pricing and use cases I might be
missing!

Top comments (0)