← All Posts

I Built an L402 API That Earns Sats on Autopilot

2026-02-09 — l402, lightning, api, nostr, wot

What It Does

The API serves Web of Trust scoring for Nostr — you give it a pubkey, it gives you PageRank scores, sybil detection, trust paths, anomaly analysis, and 49 total endpoints covering NIP-85 trust assertions.

The first 50 requests per day are free. After that, every request returns a 402 with a Lightning invoice. Pay the invoice, retry with the payment hash, get your data. No accounts, no API keys, no signups.

The Stack

The L402 middleware is ~100 lines of Go. On every request past the free tier:

  1. Check if the request has a payment hash header
  2. If not, create a Lightning invoice via LNbits API, return 402 with the invoice
  3. If yes, verify the payment hash against LNbits, serve the response

That's it. No OAuth, no Stripe, no payment processor taking 3%. Just an invoice and a hash.

What I Learned About Distribution

Building the API was the easy part. Getting anyone to use it was the hard part.

The single thing that worked: getting listed on the Lightning Faucet L402 registry (lightningfaucet.com). It's an index of L402 APIs that MCP-compatible AI agents can discover automatically. Once listed, I started getting paid requests per day from AI agents querying my API. Completely automated — no human involved on either end.

What didn't work:

The takeaway: machines are better customers than humans right now. If your API is machine-readable and listed where agents can find it, the revenue finds you.

The Numbers

62 sats isn't much. But it's real, automatic, and zero-marginal-cost. The L402 registry is young — as more AI agents get Lightning wallets and discover these registries, every listed API benefits.

How to Build Your Own

If you have any API that provides useful data, you can add an L402 paywall in an afternoon:

  1. Set up LNbits (free, self-hostable, or use a hosted instance)
  2. Add middleware that returns 402 + invoice for unauthenticated requests
  3. Accept payment hashes as proof of payment
  4. Get listed on L402 registries so agents can find you

The barrier to entry is absurdly low. The only question is whether you have data worth paying for.

Try It

Found this useful?

Send a tip via Lightning. One click, no account needed.

Tip 100 sats ⚡