我推出兩個供 AI 智能體使用的 L402 API:10 sats 獲取清理後的數據,2,500 sats 查詢 mempool 交易分析
I launched two L402 APIs for AI agents — clean data for 10 sats, mempool forensics for 2,500
作者推出兩個可透過 Bitcoin Lightning 付款的 L402 API:10 sats 可將原始網頁內容轉為結構化 JSON,2,500 sats 可分析 Bitcoin 交易並比較 BTC 即時價格,以識別套利價差。服務無需帳戶或 API keys,使用者付款後提交付款證明即可取得數據;目前仍在免費託管方案上運行,且沒有付費客戶。
AI agents can write code, browse the web and run tools — but the moment they need to pay for an API, the flow collapses into human infrastructure: signups, API keys, credit cards, monthly plans.
L402 fixes that. The payment is the credential. So I built two production-light APIs that any agent (or human) can consume autonomously over Bitcoin Lightning, and put them live:
🔗 https://l402-ai-gateway.onrender.com
What's for sale
| Endpoint | Price | What it does |
|---|---|---|
POST /v1/data/clean-scrape |
10 sats | Takes raw web content and returns clean, structured JSON an LLM can consume directly |
POST /v1/forensic/mempool-arbitrage-audit |
2,500 sats | Analyzes a real Bitcoin transaction (fee rate, RBF signaling, inputs/outputs, confirmations) using live mempool.space data, and compares live BTC prices across Kraken, Coinbase and Bitstamp to flag arbitrage spreads |
No accounts. No keys. You call, you get a 402, you pay the Lightning invoice, you retry with the proof, you get the data.
How the paywall works
The middleware is protocol-standard, not a custom hack:
- Request without payment →
402 Payment Requiredwith aWWW-Authenticate: L402 macaroon="…", invoice="lnbc…"header (plus the same data as JSON). - The macaroon is HMAC-chained and attenuated by endpoint, payment hash, amount and expiry — a token bought for the 10-sat endpoint is rejected on the 2,500-sat one.
- Pay the invoice (issued by a real LNbits wallet) → you get the preimage.
- Retry with
Authorization: L402 <macaroon>:<preimage>→ the server verifiessha256(preimage) == payment_hashlocally and serves the result.
It works out of the box with standard tooling like Lightning Labs' lnget — point it at an endpoint and the pay-and-retry cycle is automatic.
Discovery is built in too: a machine-readable manifest at /.well-known/l402.json, public pricing at /pricing, interactive OpenAPI docs at /docs, and the service announces itself on Nostr with NIP-89 handler events (kind 31990) so agents can find it without me doing marketing.
Under the hood: FastAPI, an in-memory TTL cache (repeat calls are cheap), and live upstream data — nothing in the forensic report is mocked.
Honest limitations
This is a launch, not a victory lap:
- It runs on a free hosting tier that sleeps when idle — the first call can take a few seconds to wake up.
- The receiving wallet is a custodial LNbits demo instance. Fine for the first sats, not where I'd keep real revenue.
- It currently has zero paying customers. That's why this post exists.
Try it / break it
The cheapest call costs 10 sats — less than a cent. If you're building agents, trading bots or L402 tooling, I'd genuinely love for you to:
- Hit the endpoint and run the full pay flow.
- Tell me what the output is missing for your use case.
- If it fits, I'm helping the first 10 builders integrate it for free (the calls themselves stay at list price — a real 10-sat payment is the feedback signal I care about).
Docs and manifest are public, the code structure is a standard FastAPI service, and the paywall answers with a real invoice from a real wallet. The machine economy needs services that are actually buyable by machines — this is my first one.
What should the third endpoint be?
來源:DEV Community · dev.to