Show HN: SatsAPI – Bitcoin data API, pay per call in sats via Lightning L402
3 points
1 month ago
| 2 comments
| satsapi.dev
| HN
Hi HN, I built SatsAPI — a Bitcoin market intelligence API that uses L402 (HTTP 402 + Lightning Network) for pay-per-call access instead of API keys or subscriptions.

The flow:

  GET /v1/price
  → 402 + { invoice: "lnbc3n1p...", payment_hash: "abc123" }
  
  pay invoice (any Lightning wallet)
  
  GET /v1/price?payment_hash=abc123
  → 200 + { price, rsi, macd, trend, ... }
8 endpoints covering price/technicals, mempool fees, on-chain metrics, derivatives, AI-generated signals and a full market summary. Costs range from 2 sats (~$0.001) to 200 sats (~$0.12).

The main thing I wanted to test: can L402 work as a real auth mechanism for a production API? Turns out yes — it's been live for a week on mainnet and already receiving payments from what looks like bots or automated scripts hitting multiple endpoints in sequence.

A few things I learned building this:

- phoenixd makes the Lightning side trivial. The entire payment middleware is ~60 lines of Express code. - L402 is a genuinely better model than API keys for programmatic access. No credential to leak, natural rate limiting through economics, agents can pay autonomously. - Railway blocks exchange IPs so derivatives data is estimated from price momentum rather than real funding rates. Documented but worth knowing.

Stack: Node.js/Express on Railway, phoenixd 0.7.2 on DigitalOcean.

https://satsapi.dev/docs — full docs with JS/Python/cURL examples https://satsapi.dev/health — live node status https://github.com/Aperezvigoa/satsapi — source

Happy to answer questions about the L402 implementation or the phoenixd setup.

Aperezvigoa
1 month ago
[-]
Update: recorded a demo showing the full autonomous payment flow — 402, Lightning payment, bot_ready response.

https://x.com/aperezvigoa/status/2030996046273302876?s=20

reply
andirk
1 month ago
[-]
> "It enables micropayments directly in the HTTP layer"

VERY cool! This is the perfect use of micropayments that far exceeds that of traditional fiat and credit vehicles.

reply
Aperezvigoa
1 month ago
[-]
Exactly!! and I think that's the underrated part of L402.

It's not just a payment mechanism, it's a new primitive for HTTP itself. The protocol already has a 402 status code that's been sitting unused since 1991. Lightning makes it finally usable.

The interesting implication for AI agents: they can acquire access to resources autonomously, without any human provisioning a credential. The agent just pays. That changes how you architect systems that need to consume external data or services.

Still early.. most developers haven't seen a 402 response in production before. But the primitives are all there now.

reply