DEV Community

Cover image for Pay for APIs with USDC — Build an x402 Payment Proxy in 10 Minutes
scotia1973-bot
scotia1973-bot

Posted on

Pay for APIs with USDC — Build an x402 Payment Proxy in 10 Minutes

What is x402?

x402 is a payment protocol that lets you charge users for API access using USDC on Base. No credit cards, no Stripe, no bank account needed. Just crypto.

Every request carries a micropayment. If they pay, they get the data. If not, they get a 402 Payment Required.

Why Build This?

  • Users don't want another subscription. They want to pay per use.
  • You don't want to process payments. x402 handles it.
  • Base is cheap. Transactions cost fractions of a cent.

Setup in 10 Minutes

Step 1: Install

npm install x402
Enter fullscreen mode Exit fullscreen mode

Step 2: Connect to the Proxy

import x402 from 'x402';

const proxy = x402.init({
  endpoint: 'https://api.gadgethumans.com/v1/proxy',
  wallet: '0xYOUR_WALLET_ADDRESS'
});

// Now any API call is auto-charged
const data = await proxy.get('https://api.example.com/data');
// Behind the scenes: sends USDC payment, gets response
Enter fullscreen mode Exit fullscreen mode

Step 3: One Curl Command to Start Accepting Payments

curl -X POST https://api.gadgethumans.com/v1/proxy/register \
  -H "Content-Type: application/json" \
  -d '{"endpoint": "https://yourapi.com/data", "price_usdc": 0.01}'
Enter fullscreen mode Exit fullscreen mode

That's it. Your API is now monetized. Users pay 0.01 USDC per call, you collect 99.5% (we take 0.5%).

Test It Live

curl -s https://x402.gadgethumans.com/v1/health
# → {"status": "ok", "network": "base", "price_per_call": "0.01 USDC"}
Enter fullscreen mode Exit fullscreen mode

Why This Works

  1. Devs have crypto wallets. Every web3 developer has USDC.
  2. No signup. No Stripe account, no KYC, no monthly minimums.
  3. Instant settlement. Payments arrive in your wallet in seconds.
  4. Free to start. 100 transactions/month free. $4.99/mo for Pro.

What's Next

  • Dashboard coming next week — see all your API revenue in one place
  • Webhook notifications when you get paid
  • Automatic invoice generation

Built with x402 v1.2.0 on Base (eip155:8453). Commission: 0.5%. Questions? Join our Discord.

Top comments (0)