What is Nostr?
calle 👁️⚡👁️
npub12rv…85vg
2023-03-05 03:17:14

calle 👁️⚡👁️ on Nostr: X-Cashu – HTTP 402: Payment Required Sell anonymous API access with Lightning + ...

X-Cashu – HTTP 402: Payment Required

Sell anonymous API access with Lightning + Cashu. Paid APIs require ecash in the X-Cashu http header.

Incredible anonymity for users: The server does not know which user has accessed which endpoint. The initial Lightning payment for the "top up" can't be linked to the actual API use. This is freaking awesome! 🔥

Screenshot 1:

- Hit a free endpoint without ecash, all good ✅
- Hit a paid endpoint without ecash, get 402 ❌
- Hit a paid endpoint with ecash, all good ✅

Result of some basic performance tests:

- 1000 requests without Cashu: 3.6s
- 1000 requests with Cashu: 8.5s

That's not too bad!

Implementation:

The server-side implementation is a Python FastApi middleware. It is literally plug and play and extremely simple since Cashu is a library you can include.

The client-side implementation is a Cashu wallet that puts ecash into HTTP headers before each request. This is also in Python (using requests lib) but I'll make a minimal Javascript version to demonstrate its use in a web browser.

This is the best thing since Cashu.

Author Public Key
npub12rv5lskctqxxs2c8rf2zlzc7xx3qpvzs3w4etgemauy9thegr43sf485vg