{
  "markdown": "<div align=\"center\">\n\n<picture>\n  <source media=\"(prefers-color-scheme: dark)\" srcset=\"https://raw.githubusercontent.com/ShinyDapps/l402-kit/main/docs/logo-dark.svg\" height=\"72\">\n  <img src=\"https://raw.githubusercontent.com/ShinyDapps/l402-kit/main/docs/logo-light.svg\" height=\"72\" alt=\"l402-kit\">\n</picture>\n\n# l402-kit\n\n**Add Bitcoin Lightning pay-per-call to any API. 3 lines of code.**\n\n[![License: MIT](https://img.shields.io/badge/license-MIT-yellow.svg)](LICENSE)\n[![Live Demo](https://img.shields.io/badge/▶_live_demo-end--to--end-f7931a)](https://docs.l402kit.com/introduction)\n[![Tests](https://img.shields.io/endpoint?url=https://l402kit.com/api/badges/tests)](https://github.com/ShinyDapps/l402-kit)\n[![l402-kit MCP server](https://glama.ai/mcp/servers/ShinyDapps/l402-kit/badges/score.svg)](https://glama.ai/mcp/servers/ShinyDapps/l402-kit)\n\n<br/>\n\n<a href=\"https://marketplace.visualstudio.com/items?itemName=ShinyDapps.shinydapps-l402\" title=\"VS Code Extension — real-time Lightning payment dashboard\">\n  <img src=\"https://vsmarketplacebadges.dev/version/ShinyDapps.shinydapps-l402.svg\" alt=\"VS Code Marketplace\" />\n  <img src=\"https://vsmarketplacebadges.dev/installs-short/ShinyDapps.shinydapps-l402.svg\" alt=\"Installs\" />\n</a>\n\n<br/>\n\n**[▶ Watch end-to-end demo — install → 402 → pay → 200 OK](https://docs.l402kit.com/introduction)**\n\n<br/>\n\n---\n\n### Live traction\n\n| SDK | Version | Downloads |\n|:----|:-------:|----------:|\n| 📦 **TypeScript** · [npmjs.com/package/l402-kit](https://npmjs.com/package/l402-kit) | [![npm](https://img.shields.io/npm/v/l402-kit?color=f7931a&label=)](https://npmjs.com/package/l402-kit) | [![npm total](https://img.shields.io/npm/dt/l402-kit?color=f7931a&label=total%20dls)](https://npmjs.com/package/l402-kit) |\n| 🐍 **Python** · [pypi.org/project/l402kit](https://pypi.org/project/l402kit) | [![pypi](https://img.shields.io/pypi/v/l402kit?color=3776ab&label=)](https://pypi.org/project/l402kit) | [![pypi total](https://img.shields.io/pepy/dt/l402kit?color=3776ab&label=total%20dls)](https://pypi.org/project/l402kit) |\n| 🦀 **Rust** · [crates.io/crates/l402kit](https://crates.io/crates/l402kit) | [![crates](https://img.shields.io/crates/v/l402kit?color=ce422b&label=)](https://crates.io/crates/l402kit) | [![crates dls](https://img.shields.io/crates/d/l402kit?color=ce422b&label=total%20dls)](https://crates.io/crates/l402kit) |\n| 🔌 **VS Code Extension** · [marketplace](https://marketplace.visualstudio.com/items?itemName=ShinyDapps.shinydapps-l402) | [![vscode ver](https://vsmarketplacebadges.dev/version-short/ShinyDapps.shinydapps-l402.svg)](https://marketplace.visualstudio.com/items?itemName=ShinyDapps.shinydapps-l402) | [![marketplace](https://img.shields.io/badge/VS%20Code-install-007acc)](https://marketplace.visualstudio.com/items?itemName=ShinyDapps.shinydapps-l402) |\n| 🦫 **Go** · [pkg.go.dev](https://pkg.go.dev/github.com/shinydapps/l402-kit/go) | [![go](https://img.shields.io/badge/go-v1.10.0-00acd7)](https://pkg.go.dev/github.com/shinydapps/l402-kit/go) | [![go report](https://img.shields.io/badge/go%20report-A+-00acd7)](https://goreportcard.com/report/github.com/shinydapps/l402-kit/go) |\n\n---\n\n</div>\n\n---\n\n<details>\n<summary>🌍 Available in 11 languages — click to expand</summary>\n\n<br/>\n\n🇺🇸 **Charge for your API in Bitcoin Lightning. 3 lines of code.**\n🇧🇷 Monetize sua API com Bitcoin Lightning. 3 linhas de código.\n🇪🇸 Monetiza tu API con Bitcoin Lightning. 3 líneas de código.\n🇨🇳 用 3 行代码，通过比特币闪电网络收费。\n🇮🇳 अपने API को Bitcoin Lightning से 3 लाइनों में मोनेटाइज़ करें।\n🇸🇦 اكسب من API الخاص بك عبر Bitcoin Lightning. 3 أسطر فقط.\n🇫🇷 Monétisez votre API en Bitcoin Lightning. 3 lignes de code.\n🇩🇪 Monetarisiere deine API mit Bitcoin Lightning. 3 Zeilen Code.\n🇷🇺 Монетизируй свой API через Bitcoin Lightning. 3 строки кода.\n🇯🇵 Bitcoin LightningでAPIを3行で収益化。\n🇮🇹 Monetizza la tua API con Bitcoin Lightning. 3 righe di codice.\n\n📖 **Official docs:** [🇺🇸](https://l402kit.com/docs) · [🇧🇷](https://l402kit.com/docs/pt/introduction) · [🇪🇸](https://l402kit.com/docs/es/introduction) · [🇨🇳](https://l402kit.com/docs/zh/introduction) · [🇮🇳](https://l402kit.com/docs/hi/introduction) · [🇸🇦](https://l402kit.com/docs/ar/introduction) · [🇫🇷](https://l402kit.com/docs/fr/introduction) · [🇩🇪](https://l402kit.com/docs/de/introduction) · [🇷🇺](https://l402kit.com/docs/ru/introduction) · [🇯🇵](https://l402kit.com/docs/ja/introduction) · [🇮🇹](https://l402kit.com/docs/it/introduction)\n\n</details>\n\n---\n\n## Install\n\n```bash\nnpm install l402-kit        # TypeScript / Node.js / Express\npip install l402kit         # Python / FastAPI / Flask\ngo get github.com/shinydapps/l402-kit/go@v1.10.0   # Go / net/http / Chi / Gin\ncargo add l402kit           # Rust / axum\n```\n\n> **AI Agents / LLMs:** See [`llms.txt`](./llms.txt) for machine-readable instructions.\n> **Agent discovery:** [`/.well-known/agent.json`](https://l402kit.com/.well-known/agent.json) · [`/.well-known/l402.json`](https://l402kit.com/.well-known/l402.json)\n\n---\n\n## For AI Agents\n\nl402-kit is the payment layer for autonomous agents. Agents can pay for APIs without human intervention.\n\n**System prompt snippet** — add this to any agent to enable L402 payments:\n\n```\nYou have access to paid APIs via the L402 protocol.\nWhen you call an API that returns HTTP 402, use the L402Client from l402-kit\nto pay automatically with Bitcoin Lightning.\nBudget limit: {BUDGET_SATS} sats per session. Never exceed this limit.\n```\n\n**Agent SDK quickstart:**\n\n```typescript\nimport { l402Client, buildWallet } from \"l402-kit/agent\";\n\nconst client = l402Client({\n  wallet: buildWallet(process.env), // auto-detects BLINK_API_KEY or ALBY_TOKEN\n  budgetSats: 1000,\n});\n\nconst data = await client.fetch(\"https://api.example.com/paid-endpoint\");\n```\n\n**MCP Server** (for Claude Desktop, Cursor, and any MCP-compatible agent):\n\n```json\n{\n  \"mcpServers\": {\n    \"l402-kit\": {\n      \"command\": \"npx\",\n      \"args\": [\"l402-kit-mcp\"],\n      \"env\": { \"BLINK_API_KEY\": \"your-key\" }\n    }\n  }\n}\n```\n\n**Compatible with:** LangChain · OpenAI Agents · CrewAI · Vercel AI SDK · AutoGPT · Any MCP client\n\n**Protocol support:** L402 (Bitcoin Lightning) · x402 (USDC/Coinbase) compatible\n\n[![Powered by L402-Kit](https://img.shields.io/badge/%E2%9A%A1_Powered_by-L402--Kit-f7931a)](https://l402kit.com)\n\n---\n\n## How it works\n\n```\n1. Client calls your API\n       ↓\n2. API returns  HTTP 402 + BOLT11 invoice + macaroon\n       ↓\n3. Client pays  (any Lightning wallet, < 1 second, any country)\n       ↓\n4. Client sends Authorization: L402 <macaroon>:<preimage>\n       ↓\n5. API verifies SHA256(preimage) == paymentHash  ✓\n       ↓\n6. HTTP 200 OK + your data\n\n── Fee flow (managed mode) ─────────────────────────────────\n   Payment → 99.7% → your Lightning Address  (instant)\n           →  0.3% → ShinyDapps\n```\n\n---\n\n## Quickstart\n\n### TypeScript\n\n```typescript\nimport express from \"express\";\nimport { l402, AlbyProvider } from \"l402-kit\";\n\nconst app = express();\n\nconst lightning = new AlbyProvider(process.env.ALBY_TOKEN!);\n\napp.get(\"/premium\", l402({ priceSats: 100, lightning }), (_req, res) => {\n  res.json({ data: \"Payment confirmed.\" });\n});\n\napp.listen(3000);\n```\n\n### Python\n\n```python\nfrom fastapi import FastAPI, Request\nfrom l402kit import l402_required\n\napp = FastAPI()\n\n@app.get(\"/premium\")\n@l402_required(price_sats=100, owner_lightning_address=\"you@yourdomain.com\")\nasync def premium(request: Request):\n    return {\"data\": \"Payment confirmed.\"}\n```\n\n### Go\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"net/http\"\n    l402kit \"github.com/shinydapps/l402-kit/go\"\n)\n\nfunc main() {\n    http.Handle(\"/premium\", l402kit.Middleware(l402kit.Options{\n        PriceSats:             100,\n        OwnerLightningAddress: \"you@yourdomain.com\",\n    }, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\n        fmt.Fprintln(w, `{\"data\": \"Payment confirmed.\"}`)\n    })))\n    http.ListenAndServe(\":8080\", nil)\n}\n```\n\n### Rust\n\n```rust\nuse axum::{middleware, routing::get, Router};\nuse l402kit::{l402_middleware, Options};\nuse std::sync::Arc;\n\n#[tokio::main]\nasync fn main() {\n    let opts = Arc::new(Options::new(100).with_address(\"you@yourdomain.com\"));\n\n    let app = Router::new()\n        .route(\"/premium\", get(|| async { \"Payment confirmed.\" }))\n        .route_layer(middleware::from_fn_with_state(opts, l402_middleware));\n\n    let listener = tokio::net::TcpListener::bind(\"0.0.0.0:8080\").await.unwrap();\n    axum::serve(listener, app).await.unwrap();\n}\n```\n\n---\n\n## Test it live\n\n```bash\n# Step 1 — triggers 402 + returns invoice\ncurl http://localhost:3000/premium\n# ← { \"error\": \"Payment Required\", \"invoice\": \"lnbc1u...\", \"macaroon\": \"eyJ...\" }\n\n# Step 2 — pay the invoice with any Lightning wallet, then:\ncurl http://localhost:3000/premium \\\n  -H \"Authorization: L402 <macaroon>:<preimage>\"\n# ← { \"data\": \"Payment confirmed.\" }\n```\n\n[▶ Try the interactive demo](https://docs.l402kit.com/introduction)\n\n---\n\n## Why not Stripe?\n\n|  | Stripe | l402-kit |\n|--|--------|----------|\n| Minimum fee | $0.30 | **< 1 sat (~$0.001)** |\n| Settlement time | 2–7 days | **< 1 second** |\n| Chargebacks | Yes | **Impossible — cryptographic proof** |\n| Requires account | Yes | **No — any Lightning wallet** |\n| AI agent support | No | **Yes — 4 SDKs, native** |\n| Countries blocked | ~50 | **0 — global by default** |\n| Reversible | Yes | **No — final on receipt** |\n| Open source | No | **Yes — MIT** |\n\n---\n\n## Providers\n\n```typescript\nimport { BlinkProvider, OpenNodeProvider, LNbitsProvider } from \"l402-kit\";\n\n// Blink (recommended — free, instant setup)\nconst provider = new BlinkProvider(process.env.BLINK_API_KEY!, process.env.BLINK_WALLET_ID!);\n\n// OpenNode (production, custodial)\nconst provider = new OpenNodeProvider(process.env.OPENNODE_KEY!);\n\n// LNbits (self-hosted)\nconst provider = new LNbitsProvider(process.env.LNBITS_KEY!, \"https://your.lnbits.host\");\n```\n\n**Bring your own node** — implement the `LightningProvider` interface in 5 lines:\n\n```typescript\nimport type { LightningProvider } from \"l402-kit\";\n\nclass MyNode implements LightningProvider {\n  async createInvoice(amountSats: number) { /* return Invoice */ }\n  async checkPayment(paymentHash: string) { /* return boolean */ }\n}\n```\n\n---\n\n## Security model\n\n```\nInvoice creation:  paymentHash = SHA256(preimage)\nClient payment:    Lightning Network releases preimage to payer\nAPI verification:  SHA256(preimage) == paymentHash  ✓\nReplay protection: each preimage is marked used — works exactly once\nToken expiry:      macaroons expire after 1 hour\n```\n\n- **Unforgeable** — SHA256 is a one-way function; you cannot fake a preimage\n- **No chargebacks** — cryptographic settlement, not reversible card auth\n- **Replay-safe** — MemoryReplayAdapter (dev) or RedisReplayAdapter (production, multi-instance)\n- **600+ automated tests** across 5 runtimes (TS, Python, Go, Rust, Cloudflare Workers) — production-grade reliability for autonomous agent workflows\n- **Fully auditable** — MIT, every line open source\n\n---\n\n## VS Code Extension\n\nMonitor every sat in real-time without leaving your editor.\n\n[![VS Code Marketplace](https://vsmarketplacebadges.dev/version/ShinyDapps.shinydapps-l402.svg)](https://marketplace.visualstudio.com/items?itemName=ShinyDapps.shinydapps-l402)\n\n- ⚡ Live payment feed per endpoint\n- 📊 Bar chart — 1D / 7D (free) · 30D / 1Y / ALL (Pro)\n- 🌍 11 languages built-in\n- 🎨 Light / dark / auto theme\n- 🔧 Zero config — just set your Lightning Address\n\n---\n\n## Get a Lightning Address (free)\n\nSign up at **[dashboard.blink.sv](https://dashboard.blink.sv)** — free, no credit card, instant.\nYour address: `yourname@yourdomain.com`\n\nOther wallets: [Wallet of Satoshi](https://walletofsatoshi.com) · [Phoenix](https://phoenix.acinq.co) · [Zeus](https://zeusln.app) · [Alby](https://getalby.com)\n\n---\n\n## Links\n\n| Resource | URL |\n|----------|-----|\n| 📖 Docs (11 languages) | [l402kit.com/docs](https://l402kit.com/docs) |\n| 📦 npm | [npmjs.com/package/l402-kit](https://npmjs.com/package/l402-kit) |\n| 🐍 PyPI | [pypi.org/project/l402kit](https://pypi.org/project/l402kit) |\n| 🦫 Go | [pkg.go.dev/github.com/shinydapps/l402-kit/go](https://pkg.go.dev/github.com/shinydapps/l402-kit/go) |\n| 🦀 Rust | [crates.io/crates/l402kit](https://crates.io/crates/l402kit) |\n| 🔌 VS Code | [marketplace.visualstudio.com](https://marketplace.visualstudio.com/items?itemName=ShinyDapps.shinydapps-l402) |\n| ⚡ Lightning | shinydapps@blink.sv |\n| 🐙 GitHub | [github.com/ShinyDapps/l402-kit](https://github.com/ShinyDapps/l402-kit) |\n\n---\n\n<div align=\"center\">\n\nMIT — use freely, build freely.\n\n**Bitcoin has no borders.**\n\n<br/>\n\nBuilt with ⚡ by [ShinyDapps](https://github.com/ShinyDapps)\n\n<br/>\n\n<a href=\"https://l402kit.com/docs\">Docs</a> · <a href=\"https://docs.l402kit.com/introduction\">Demo</a> · <a href=\"https://marketplace.visualstudio.com/items?itemName=ShinyDapps.shinydapps-l402\">VS Code</a> · <a href=\"https://npmjs.com/package/l402-kit\">npm</a>\n\n</div>\n",
  "bytes": 12977,
  "sha": "9e5dea124b412988b484cb6f2b50bd40008a47c9b1a68d52278a4c8b95972cd5",
  "repo_slug": "shinydapps/l402-kit",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/mcp_io_github_thiagodataengineer_l402_kit_9357a0e7/readme"
}