Skip to main content

l402-kit ???? ???

l402-kit ?? open-source middleware ?? ?? ???? ?? ?????? ?? 3 ???? ??? ??? ???? API ??? Bitcoin Lightning micropayments ?????? ???? ??? ??? ??????? ????? ????? ??? ??????????? ????? ??? chargeback ????? ??? minimum fee ????? ????? sats?
npm install l402-kit   # TypeScript / Express
pip install l402kit    # Python / FastAPI / Flask
go get github.com/shinydapps/l402-kit/go@v1.10.0  # Go / net/http
cargo add l402kit       # Rust / axum

?? ??? ?????? ?? ?? ???? ???

  • Stripe: ????? transaction minimum $0.30 � micropayments ?? ??? ?????
  • Subscriptions: ?? ?????????? ?????? ???????????? ?? subsidize ???? ???
  • AI Agents: credit card ???? ?? � APIs ?? automatically pay ???? ?? ????
l402-kit ????? ?????? ??: Lightning Network ?? ???? pay-per-call, 1 second ?? ?? ??? global settlement?

?? ????? ??? ???

  • API Developers � monthly subscription ?? ??? per-call charge ????
  • AI Agent Builders � agents automatically APIs pay ???? ???
  • Stripe ?? ???? Devs � India, Bitcoin ?? ??? ???? ????

?????? ?????? � TypeScript

import express from "express";
import { l402 } from "l402-kit";

const app = express();

app.get("/premium", l402({
  priceSats: 100,                           // ~?5 ????? call
  lightning: new AlbyProvider(process.env.ALBY_TOKEN!, process.env.ALBY_HUB_URL!),    // ??????? ??? � 0% ?????
}), (_req, res) => {
  res.json({ data: "?????? ?????????." });
});

app.listen(3000);

?????? ?????? � Python

from fastapi import FastAPI, Request
from l402kit import l402_required

app = FastAPI()

@app.get("/premium")
@l402_required(
    price_sats=100,
    lightning=ManagedProvider.from_address("you@blink.sv"),
)
async def premium(request: Request):
    return {"data": "?????? ?????????."}

??? ????? ????

curl http://localhost:3000/premium
# ? {"error":"Payment Required","priceSats":100,"invoice":"lnbc..."}

???? Quickstart

5 ???? ??? paid API ???? ????