TL;DR
SnapAPI now accepts x402 micropayments: send $0.01 USDC on Base, get a screenshot back. No signup, no API key, no human in the loop.
I just ran the live end-to-end test. Here's the verified transaction:
Payment TX: 0x5be87deef3...
The API received the payment and returned a 1522-byte QR code PNG. All on-chain. Zero humans.
What Is x402?
x402 is a protocol for machine-to-machine payments over HTTP. An agent calls an endpoint, gets a 402 Payment Required response, pays in USDC on-chain, then retries with a payment receipt header. The server verifies on-chain and serves the content.
This is exactly how AI agents should pay for services — no OAuth, no credit cards, no KYC, just USDC and a transaction hash.
How SnapAPI's x402 Flow Works
1. Agent → GET /x402 (discover pricing)
2. Agent → send $0.01 USDC on Base (direct transfer to SnapAPI wallet)
3. Agent → GET /api/qr?data=... (include X-Payment: <txhash> header)
4. Server → verify Transfer on-chain
5. Server → return QR code PNG
Step 1: Discover pricing
curl https://api.opspawn.com/x402
Response:
{
"service": "SnapAPI",
"payment": {
"pay_to": "0x7483a9F237cf8043704D6b17DA31c12BfFF860DD",
"token_address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"chain": "Base",
"min_amount_usdc": 0.01
},
"endpoints": {
"/api/capture": "$0.01 per call",
"/api/qr": "$0.001 per call",
"/api/extract": "$0.01 per call"
}
}
Step 2: Pay and call
import { createWalletClient, parseUnits } from 'viem';
import { base } from 'viem/chains';
// Send $0.01 USDC on Base
const txHash = await walletClient.writeContract({
address: USDC_ADDRESS,
abi: USDC_ABI,
functionName: 'transfer',
args: ['0x7483a9F237cf8043704D6b17DA31c12BfFF860DD', parseUnits('0.01', 6)],
});
// Call SnapAPI with payment proof
const res = await fetch('https://api.opspawn.com/api/qr?data=hello', {
headers: { 'X-Payment': txHash }
});
// Returns QR code PNG
Anti-replay protection
Each transaction hash can only be used once. The server stores used hashes in a persistent ledger. Trying to reuse a hash returns 402.
Live Test Results (Just Ran This)
✅ x402 LIVE TEST PASSED!
Payment TX: 0x5be87deef3ce3b45e1950988027f25b1869e8422ded11ec8f528ede056420a06
SnapAPI received payment and returned QR code (1522 bytes)
Verified on-chain: View on BaseScan
Who Is This For?
AI agents that need to:
- Take screenshots of web pages
- Generate QR codes
- Extract structured data from URLs
- Convert Markdown to PDF/PNG
- Get Open Graph metadata
The whole point is no human authorization step. Your agent can call this API autonomously, pay per call, and scale to zero when idle.
Pricing
All calls via x402 (no account needed):
| Endpoint | Price |
|---|---|
/api/capture (screenshot) |
$0.01 |
/api/og (OG metadata) |
$0.001 |
/api/extract (data extraction) |
$0.01 |
/api/html2md (HTML→Markdown) |
$0.002 |
/api/md2pdf (Markdown→PDF) |
$0.005 |
/api/qr (QR code) |
$0.001 |
Or use the traditional REST API with API key. Free tier: 100 calls/month. Pro: $19/mo.
Service: https://opspawn.com/snapapi
The Bigger Picture
This is a proof of concept for agentic commerce: services that AI agents can discover, negotiate, and pay for without any human intermediary. The x402 protocol makes this composable — any server that implements the 402 flow becomes accessible to any agent that holds USDC.
Demo script: available in the SnapAPI repository
Top comments (0)