What L402 enables
L402 connects API access with a payment through the Bitcoin Lightning network. The service supplies an invoice and an access credential; after payment, the client adds proof of payment. Individual API calls or other digital services can be paid for as they are requested.
Connections with other protocols
- Like x402 and MPP, L402 addresses paid access to a resource. L402 uses Lightning invoices and cryptographic access credentials.
- Aperture from the Lightning Labs ecosystem can act as a proxy handling payment and access verification for a service.
Versions and licence
- Published version
- No separate version stated
- Working draft
- —
The JavaScript packages @lightninglabs/l402 and @lightninglabs/l402-ai are published as 0.1.0. The SDK repository contains a Rust core and Go and Python bindings; package versions are not a global protocol version.
- Licence / terms
- L402sdk: MIT OR Apache-2.0. Terms for the specification and other implementations are in their respective repositories.
Licence and terms ↗
An example flow
- A client requests a paid API. The server returns HTTP 402, a Lightning invoice and a macaroon as an access credential.
- The client pays the invoice through Lightning and receives proof of payment, called the preimage.
- It repeats the request with the macaroon and preimage in the Authorization header.
- The server checks both and delivers the requested resource.
SDKs and examples
These libraries and examples help you get started. Each entry lists the language, package and supported version.
L402 JavaScript SDKs
Includes: JavaScript SDK and AI integrations
Package / module: @lightninglabs/l402; @lightninglabs/l402-ai
Version & compatibility: Both 0.1.0 · Published 15 April 2026
L402 Rust core and language bindings
Includes: Rust source, Go CGo and Python bindings
Version & compatibility: Source and build instructions in the L402sdk repository
Rust core with Go CGo and Python bindings; build instructions are in the SDK repository.
Practical integration
- A macaroon can restrict access to particular services or a narrower scope of use.
- The SDKs listed here are from Lightning Labs. The PyPI name l402 refers to a separate library published by Fewsats.