L402 protocol — machines pay machines. Bring your Lightning node or ours. No middleman required.
Real HTTP headers. Real Lightning invoice. Watch request → 402 → pay → 200.
Click ▶ Run to simulate · Try with a real Lightning wallet →
// npm install l402-kit — AI agent consuming an L402-protected API import { L402Client } from "l402-kit"; import { AlbyProvider } from "l402-kit"; // Agent has its own Lightning wallet — pays autonomously const client = new L402Client({ wallet: new AlbyProvider(process.env.ALBY_TOKEN!, process.env.ALBY_URL!), }); // Automatic: 402 detected → pays invoice → retries → returns data const res = await client.fetch("https://any-l402-api.com/data"); const data = await res.json(); // → 200 OK — paid in <1s, no human involved, no API key, no subscription
// npm install l402-kit — protect your API (sovereign, 0% fee) import express from "express"; import { l402, AlbyProvider } from "l402-kit"; const app = express(); const lightning = new AlbyProvider( process.env.ALBY_TOKEN!, // hub.getalby.com — self-custodial process.env.ALBY_URL! ); app.get("/premium", l402({ priceSats: 100, lightning }), (req, res) => { res.json({ data: "Payment confirmed ⚡" }); }); app.listen(3000); // 0% fee. Your node. Every sat goes directly to you.
# pip install l402kit — protect your FastAPI endpoint (sovereign) from fastapi import FastAPI from l402kit import l402_required, BlinkProvider app = FastAPI() lightning = BlinkProvider( api_key="your_blink_key", # dashboard.blink.sv — free wallet_id="your_wallet_id" ) @app.get("/premium") @l402_required(price_sats=100, lightning=lightning) async def premium(): return {"data": "Payment confirmed ⚡"}
// go get github.com/shinydapps/l402-kit/go package main import ( "fmt"; "net/http" l402kit "github.com/shinydapps/l402-kit/go" ) func main() { http.Handle("/premium", l402kit.Middleware(l402kit.Options{ PriceSats: 100, Provider: l402kit.NewBlinkProvider(os.Getenv("BLINK_KEY"), os.Getenv("BLINK_WALLET")), }, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { fmt.Fprintln(w, `{"data":"Payment confirmed ⚡"}`) }))) http.ListenAndServe(":8080", nil) }
// Cargo.toml: l402kit = "0.1" use axum::{middleware, routing::get, Router}; use l402kit::{l402_middleware, Options}; use std::sync::Arc; async fn handler() -> &'static str { "{\"data\":\"Payment confirmed ⚡\"}" } #[tokio::main] async fn main() { let opts = Arc::new( Options::new(100).with_address("you@yourdomain.com"), ); let app = Router::new() .route("/premium", get(handler)) .route_layer(middleware::from_fn_with_state(opts, l402_middleware)); let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap(); axum::serve(listener, app).await.unwrap(); }
Stripe was built for humans buying products. APIs charge per-call — and that breaks everything.
| Card processors | PayPal / legacy | l402-kit ⚡ | |
|---|---|---|---|
| Minimum fee | $0.30 | $0.30 | < 1 sat |
| Settlement | 2–7 days | 3–5 days | < 1 second |
| Chargebacks | Yes | Yes | Impossible |
| Requires account | Yes | Yes | No |
| AI agent native | No | No | Yes |
| Countries blocked | ~50 | ~60 | 0 — global |
| Open source | No | No | 100% |
You own the API. You keep 99.7% of every sat.
See every payment in real time, with live charts and instant notifications. No setup, no account, no permissions required. Works with TypeScript, Python, Go, Rust and more.
Pay with Bitcoin Lightning. No credit card. No account. Instant.
No card. No account. Pay with Bitcoin · Cancel anytime · Your data, your control — delete anytime ↗
Trusted by developers building on Bitcoin
"Finally, a payments lib that treats Bitcoin as first-class. 3 lines and it just works."
"My AI agent now pays for its own API calls. No wallets, no keys, no human approval."
Open source · MIT · Star on GitHub ⭐
No account. No credit card. Just Bitcoin Lightning.
Most payment APIs need your email, credit card, and account. l402-kit needs none of that — your Lightning wallet is cryptographic proof of who you are.
Follow releases on GitHub — star the repo and enable notifications. No email required, no account, no tracking.
⭐ Star on GitHubNo email · No tracking · Bitcoin-native