Bitcoin  ·  Lightning  ·  HTTP 402
⚡ MIT Open Source · TypeScript · Python · Go · Rust · AI-native

Toda API é uma troca.
Paga via Lightningsem intermediário.

3 linhas de código. Sem Stripe. Sem cadastro. Agentes de IA pagam nativo — máquinas pagam máquinas.

l402-kit · live payment flow
curl https://api.example.com/data
← 402 Payment Required
← invoice: lnbc1sat1p5xm4q8pp5q...  macaroon: eyJoYXNoIjoi...
Paying 1 sat...
← 200 OK
← {"btc":"$95,000","settled":"<500ms","protocol":"L402"}
① client request ② lightning payment ③ instant access
Read the docs →

Try it live

A real 402 response.
From a real API.

Hit VERITY — an autonomous AI agent earning sats on l402-kit at l402kit.com/api/verity. You'll get the actual Lightning invoice and macaroon. No payment needed to see them.

$ curl https://l402kit.com/api/verity/btc-price
Click Run → to see VERITY's live 402 response. Macaroon and invoice will be real and valid.

An AI agent would pay this invoice over Lightning, then retry with Authorization: L402 <macaroon>:<preimage> to get the data. That's the entire L402 protocol — and three lines of code with l402-kit.


How it works

Two sides. One protocol.

L402 connects API sellers and AI buyers — same 3-line SDK, no middleman.

CLIENT L402 GATE API SERVER HTTP 402 200 OK
① request blocked ② ⚡ lightning pay ③ instant access
Any API · Any amount · Anywhere · <1 second
🏗️ API Developer — sell
1
Add 3 lines of middleware
l402({ priceSats: 10, lightning })
2
Client hits your endpoint → gets 402
Invoice + macaroon returned automatically
3
Payment verified · 200 OK returned
SHA256(preimage) == hash — <1ms, no DB
99.7% lands in your Lightning wallet
Instantly — managed mode, no node needed
Start selling in 2 min →
🤖 AI Builder — buy
1
Configure wallet + budget
new L402Client({ wallet, budgetSats: 1000 })
2
client.fetch() hits the API → gets 402
SDK extracts invoice + macaroon
3
Pays invoice → retries with proof
Authorization: L402 <macaroon>:<preimage>
200 OK + data — no human in the loop
Works with any LLM framework
Agent quickstart →

MIT
License
120+
GitHub stars
92
Tests passing
300+
Total installs
50+
npm downloads/wk
<1s
Settlement time
0
Countries blocked

Managed mode

No node. No wallet setup.
Just your Lightning Address.

l402kit.com hosts the Lightning node for you. Every payment splits automatically: 99.7% goes straight to your address, 0.3% keeps the project alive. Or self-host for 0%.

No Lightning node required
We host the infrastructure — you just receive sats.
🌍
Any Lightning Address works
Blink, Alby, Strike, Wallet of Satoshi — if it has a Lightning Address, you're good.
🔀
Switch to self-host anytime
Change one line to Blink, LNbits, or BTCPay — 0% fee, your node, your rules.
managed vs. soberano
// Managed — no setup, 0.3% fee
const lightning = ManagedProvider.fromAddress("you@domain.com");
// Soberano — your node, 0% fee
const lightning = new BlinkProvider(process.env.BLINK_TOKEN);
// Same middleware either way ↓
app.get("/api/data", l402({ priceSats: 10, lightning }), handler);

Cost comparison — live BTC price
Feature Stripe PayPal l402-kit ⚡ x402 (USDC)
Min. fee per call $0.30 $0.30 1 sat ≈ ... ~$0.001 USDC
Cost: 1,000 calls $300 $300 ... (live) ~$1 USDC
Cost: 1M calls $300,000 $300,000 ... (live) ~$1,000 USDC
Settlement 2–7 days 3–5 days < 1 second ~seconds (Base)
Requires account Yes Yes No No (wallet)
AI agent native No No Yes Yes
Countries blocked ~50 ~60 0 — global ~few (OFAC)
Chargeback risk Yes Yes Impossible Impossible
Currency Fiat (USD) Fiat (USD) Bitcoin ⚡ USDC (stablecoin)
l402-kit compatible No No Native ✓ Compatible

Assuming 100 sats/call at current BTC price — updates live


What will you build?

Use cases

AI / Agents
Monetize your AI tool
Charge per inference call. LLM wrappers, image gen, OCR APIs. Works natively with LangChain and AutoGPT agents.
l402({ priceSats: 100, lightning })
Data APIs
Pay-per-query data
Weather, finance, sports, maps. No subscription needed — users pay exactly for what they use.
l402({ priceSats: 10, lightning })
Content
Paywalled endpoints
Articles, research papers, PDFs, audio. No account creation required from your users.
l402({ priceSats: 50, lightning })
Compute
Serverless billing
Charge for CPU-heavy tasks: rendering, transcription, compression. Pure usage-based, no monthly fee.
l402({ priceSats: 500, lightning })

▶ Interactive Demo

The full L402 flow, live

Watch the full L402 flow: request → 402 → pay → 200.

🏪 SELLER — API provider Add 3 lines, start earning
Managed ☁
⚡ AI Agent
TypeScript
Python
Go
Rust
// npm install l402-kit  — AI agent consuming an L402-protected API
import { L402Client, AlbyWallet } from "l402-kit";

// Agent has its own Lightning wallet — pays autonomously
const client = new L402Client({
  wallet: new AlbyWallet(process.env.ALBY_TOKEN!),
  budgetSats: 1000,
});

// 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 (soberano, 0% fee)
import express from "express";
import { l402, BlinkProvider } from "l402-kit";

const app = express();
const lightning = new BlinkProvider(
  process.env.BLINK_API_KEY!,
  process.env.BLINK_WALLET_ID!
);

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.
// npm install l402-kit  — managed mode: no node, no wallet setup
import express from "express";
import { l402, ManagedProvider } from "l402-kit";

const app = express();

// l402kit.com hosts the Lightning node — no setup needed
const lightning = ManagedProvider.fromAddress("you@yourdomain.com");
// ↑ payments go directly to your Lightning address (99.7% of each sat)

app.get("/api/data", l402({ priceSats: 10, lightning }), (req, res) => {
  res.json({ data: "Payment confirmed ⚡" });
});

app.listen(3000);
// Fee: 0.3% to l402kit.com · 99.7% to you · TypeScript only
# pip install l402kit  — protect your FastAPI endpoint (soberano)
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();
}
⚡ BUYER — API client Calls the API, pays in sats
l402-kit · HTTP 402 Payment Required
$

Click ▶ Run to simulate  ·  Open live L402 endpoint →

⚡ Live Demo

Try L402 live — pay 1 sat ⚡

Click ▶ Run — get a real BOLT11 invoice. Pay 1 sat from any Lightning wallet, paste the preimage, and unlock the whitepaper. Real L402 flow: 402 → invoice → pay → whitepaper unlocked. No account. No signup.

l402-kit · live L402 demo
# Click ▶ Run — get a real BOLT11 invoice via L402
Get started in 2 minutes

Your API.
Your Bitcoin.
No middleman.

3 lines of middleware. Zero config option. Every sat lands directly in your Lightning wallet.

🔓 MIT License ⚡ TypeScript · Python · Go · Rust 🚫 No account needed 0️⃣ 0% fee (self-host)
Read the docs → ⭐ Star on GitHub
$ npm install l402-kit
0.3% managed fee · or 0% self-host Full quickstart →
[·-·] [·-·]
AI agents pay natively
machines pay machines
Or scaffold: npx create-l402-app my-api

Two kinds of builders

Who is this for?

You own the API. You keep 99.7% of every sat.

🏗️
API Developer
You sell data or compute
You built an API — weather, AI inference, market data, media — and want to monetize it per call without Stripe, subscriptions, or billing dashboards.
  • Add 3 lines of middleware
  • Set your price in sats
  • Receive Bitcoin instantly
Start building →
🤖
AI Builder
Your agent needs to pay for tools
You're building autonomous AI agents that call external APIs. L402 is the native payment protocol for agents — no OAuth, no card on file, no human approval loop.
  • Agent gets 402 → pays invoice
  • Retries with proof → gets data
  • Works with any LLM framework
Agent guide →
Built with l402-kit
Diagram Forge
AI that analyzes any GitHub repo and generates architecture diagrams — charged per analysis in sats, no account needed. Uses ManagedProvider with 3 lines of middleware.
Try it →

Agent Economy

Machines paying machines.
This is the next economy.

AI agents already browse the web, write code, and make decisions. The only thing missing: the ability to pay for the APIs they need — without a human in the loop.

🤖
Agents can't hold credit cards
Stripe, PayPal, and every card network requires a human account. An autonomous agent has none. L402 solves this at the protocol level.
Lightning settles in <1 second
An agent making 100 API calls per minute needs instant settlement. Lightning Network: global, sub-cent, irreversible — no chargebacks, no holds.
📦
Any API. Any agent. 3 lines.
client.fetch(url) — drops into any agent loop. Budget control, auto-retry, proof verification — built in. No plumbing required.
Works with any agent framework
🤖 Claude MCP 🦜 LangChain ▲ Vercel AI SDK 🔮 OpenAI Agents 🦙 Llama Index 🐍 AutoGPT
L402Client is a drop-in fetch — if the framework calls HTTP, it works.

MCP Server

Add l402-kit to Claude
in 2 minutes.

Give Claude Desktop or Cursor a Lightning wallet. From that moment on, any AI agent running inside those tools can autonomously pay for L402 APIs — no code, no credit card.

claude_desktop_config.json
{
  "mcpServers": {
    "l402": {
      "command": "npx",
      "args": ["l402-kit-mcp"],
      "env": {
        "BLINK_API_KEY": "blink_xxx",
        "BLINK_WALLET_ID": "uuid",
        "L402_BUDGET_SATS": "1000"
      }
    }
  }
}
Tools exposed to Claude
l402_fetch
Call any L402-protected URL — pays automatically with your wallet
l402_balance
Check remaining budget and total spent this session
l402_spending_report
Full breakdown by domain — see where sats went
Works with 🤖 Claude Desktop ▲ Cursor ⚙ Any MCP client Docs →
Listed on Anthropic Glama Smithery mcp.so McpMux

API Directory

APIs that agents can pay. Right now.

Every API below accepts Lightning micropayments via L402 — no API key, no subscription, no human in the loop.

Loading…

Agent quickstart → + Register my API

Pricing

Precos simples

Pague com Bitcoin Lightning. Sem cartao. Sem conta. Instantaneo.

⚡ The SDK is always free — MIT, open source, no account.  |  0.3% fee applies only in managed mode — self-host for 0%.  |  Plans below: analytics dashboard.
Soberano
$0 forever
0% fee — SDK always free
Self-host with your own Lightning node
  • TypeScript, Python, Go, Rust
  • Self-host = 0% fee, forever
  • Unlimited API calls
  • Payment history (7 days)
  • Charts 1D / 7D
  • Open source — MIT
Set up your node →
Pro
$9 /month
≈ 11k sats today/mo
Pay with Lightning — instant activation
  • Everything in Soberano
  • Full history — no 7-day limit
  • All chart ranges (30D / 1Y / ALL)
  • CSV export
  • Lightning receipt — verifiable proof
  • Delete all your data anytime

No card. No account. Pay with Bitcoin · Cancel anytime · Your data, your control — delete anytime ↗


FAQ

Perguntas comuns

Meus usuarios precisam de wallet Lightning?
Sim. Eles precisam de uma wallet Lightning para pagar. Para agentes de IA, a wallet pode ser controlada por codigo.
E se a Lightning ficar fora do ar?
A Lightning e descentralizada e muito resiliente. Se um provider cair, voce troca por outro em uma linha.
Ja esta pronto para producao?
Sim. Prova criptografica, protecao anti-replay e logs no Supabase ja estao incluidos.
Como funciona a taxa de 0.3%?
No modo managed, a taxa de 0.3% e deduzida automaticamente. Em self-host, a taxa e 0%.
Posso usar sem Blink?
Sim. OpenNode, LNbits ou qualquer provider que implemente a interface LightningProvider.
Why Lightning and not on-chain Bitcoin?
On-chain Bitcoin takes 10+ minutes to confirm and costs $1–5 per transaction. Lightning settles in under a second for fractions of a cent — making $0.001 micropayments economically viable. If you bring your own wallet, your keys never leave your control. The payment proof (SHA256 preimage) is verified locally on your server — no third party involved.
How is this different from Coinbase's x402?
x402 is a protocol specification — it defines how HTTP 402 payments should work. l402-kit is a production-ready SDK that implements that same standard today, in TypeScript, Python, Go, and Rust. Coinbase's x402 targets USDC and stablecoins. l402-kit targets Bitcoin Lightning. They're complementary, not competing — and we're shipping code while they're publishing specs.
Is the 0.3% fee always charged?
No. The fee only applies if you use our managed infrastructure (add your Lightning address, we handle invoice creation). If you connect your own wallet — Blink account, OpenNode, LNbits, BTCPay, any provider — the fee is zero. You can switch at any time with one line of code. The open-source MIT license means you can self-host everything with no fees ever.

VS CODE EXTENSION

Watch your sats roll in —
without leaving your editor

Real-time Lightning payment dashboard inside VS Code. See every payment the instant it lands — endpoint hit, amount in sats, USD value, and a live chart.

  • ✓ Live payment feed with amount & endpoint
  • ✓ Bar chart — 1D / 7D (free) · 30D / 1Y / ALL (Pro)
  • ✓ 11 languages (EN, PT, ES, ZH, JA, FR, DE, RU, HI, AR, IT)
  • ✓ First payment notification — instant VS Code alert
  • ✓ Zero config — just set your Lightning address
Install Free on Marketplace Documentation →
ShinyDapps Lightning Payments
ShinyDapps Lightning Payments — VS Code extension demo
47,832 sats · 12,430 today · 6 endpoints · 6 languages shown

Still here?

You already know it works.
Time to ship.

No account. No Stripe. No middleman. Just
Bitcoin Lightning — instant, global, final.

Start in 2 minutes → ⭐ Star on GitHub

MIT · Open source · stars