Monetize Your APIs with Lightning Payments
Enable pay-per-request for any API. No subscriptions, no API keys, no accounts. Your users pay with Bitcoin Lightning and get instant access.
// Add L402 payment protection with one line
import { l402Middleware } from "paygate-l402"
app.use(
l402Middleware({
"GET /api/data": { price: 100, currency: "sats" },
"POST /api/generate": { price: 500, currency: "sats" },
})
)Everything you need to monetize your API
Built on the L402 protocol, Clobig gives you the tools to turn any endpoint into a revenue stream.
How L402 works
The HTTP 402 status code was reserved for "Payment Required" since 1997. L402 finally puts it to work.
Client makes HTTP request
User or AI agent sends a request to your protected endpoint without any API key or pre-registration.
fetch('/api/weather?city=miami')Server returns 402 Payment Required
Your server responds with a Lightning invoice and payment details according to the L402 protocol.
HTTP/1.1 402 Payment Required
WWW-Authenticate: L402
macaroon="...",
invoice="lnbc..."Client pays the invoice
The client pays the Lightning invoice instantly, typically in under 1 second. Payment is settled immediately.
const preimage = await wallet.pay(invoice)Access granted
Client retries with payment proof. Server validates and returns the requested data. The whole flow takes seconds.
Authorization: L402 <macaroon>:<preimage>
// Response: { "weather": "sunny", "temp": 75 }Built for the agentic future
From AI agents to data APIs, L402 enables new business models that weren't possible before.
- GPT plugins
- Autonomous workflows
- Agent-to-agent payments
- Chat completions
- Embeddings
- Custom models
- Image generation
- Voice synthesis
- Video editing
- Market data
- Weather APIs
- Research datasets
- GPU inference
- Video transcoding
- 3D rendering
- Articles
- Research papers
- Tutorials
SDKs for every language
Get started in minutes with our official SDKs. Fully open source and MIT licensed.
npm install paygate-l402pip install paygate-l402go get github.com/paygate/l402-gocargo add paygate-l402import { l402Middleware } from "paygate-l402"
import { createLightningProvider } from "paygate-l402/lightning"
// Connect to your Lightning node
const lightning = createLightningProvider({
backend: "lnd", // or "cln", "phoenixd"
macaroonPath: process.env.MACAROON_PATH,
})
// Protect your routes
export const paywall = l402Middleware({
lightning,
routes: {
"GET /api/weather": { price: 10, currency: "sats" },
"POST /api/generate": { price: 100, currency: "sats" },
"GET /api/premium/*": { price: 50, currency: "sats" },
},
})Transparent pricing
No monthly fees, no hidden costs. Pay only for what you use, or self-host for free.
- Full L402 protocol support
- All middleware integrations
- Community support
- MIT License
- Self-managed Lightning node
- Everything in Open Source
- Managed Lightning node
- Automatic channel management
- Real-time analytics dashboard
- Email support
- 99.9% uptime SLA
- Everything in Pro
- Dedicated infrastructure
- Custom integrations
- 24/7 priority support
- On-premise deployment option
- Custom SLA
Ready to monetize your API?
Join thousands of developers building the future of internet-native payments. Start accepting Lightning payments in minutes.
No credit card required. Start building in minutes.