pull down to refresh

I've implemented ngx_l402, an Nginx module that enables pay-per-request authentication using the L402 protocol. It allows API providers to monetize their endpoints via Bitcoin and the Lightning Network.
Why ngx_l402? πŸ”Ή Monetize APIs with Bitcoin payments πŸ”Ή Seamless Lightning authentication using L402 πŸ”Ή Supports generating invoices via Lightning Network Daemon (LND), Lightning URL (LNURL), and Nostr Wallet Connect (NWC) πŸ”Ή Lightweight & efficient for Nginx users
Check it out: πŸ”— GitHub: https://github.com/DhananjayPurohit/ngx_l402
Would love to hear feedback and thoughts! πŸš€βš‘
Interesting, but the readme is shy on details. Does it charge per call or per time? Both REST and WS? Suggested use cases?
reply
Thanks for pointing that out! I'll add more details to the README.
It charges per unique call. You'll need to implement a database to invalidate macaroons after each use or based on time. Currently, it supports REST APIs only; WebSocket (WS) support is not yet implemented.
Real-world use cases can be: AI & LLM APIs – Charge per request for AI model inferences, ensuring pay-per-use monetization. Weather & Financial APIs – Monetize access to premium weather forecasts, stock prices, or crypto market data. Self-hosted SaaS Tools – Implement per-request billing for services like file conversion, image processing, or data enrichment. Decentralized VPNs & Proxies – Charge users for bandwidth consumption on privacy-preserving networks.
reply
200 sats \ 3 replies \ @k00b 11 Mar
Nice works. Has @fewsats seen this?
reply
I’ve posted it on X as well. They have an uncanny ability to detect anything brewing around L402β€”it's like they can sense every innovation in the space! Huge respect for @fewsats and their efforts in making L402 a massive success. πŸš€
reply
100 sats \ 1 reply \ @fewsats 13 Mar
Ofc we have seen it.
Dhananjay thinks that we have an alert for L402 stuff but in reality we are just big fans of the things he builds so when he pushes something we notice :D
I like it more as an nginx module than as a full proxy like aperture. If someone is looking for things to build this proxy + a storage service is a good project to start with.
reply
That's really awesome to hear! I appreciate the support and the keen eye on my work. πŸ˜ƒ
reply
Great work! Will check it out.
reply
Thanks! Let me know if you have any suggestions or feature requests.
reply
Will do. I have already shared your repo with our dev at Predyx, they are super excited about what you built. We will start exploring it in depth in a month or so due to other priorities.
Question: Is there a way we can specify a separate invoice/sats amount for every unique API calls. For example we have a "buy share" API /api/predictions/buy, each unique API calls would require different sats amount to be paid. The sats amount/invoice can be passed in the http header.
reply
Thanks! For now, I've configured the amount field as an environment variable, but I plan to make it configurable per API directly from nginx.conf. Alternatively, I might explore a way to make the amount dynamic, similar to how Aperture handles it.
reply
If you can make it configurable per API using redis/memcache as source of invoice amt, that would be awesome.
reply