L402

How to use it as an API

What is L402:

L402s are essentially APIs on a Bitcoin Standard. It enables software/apps to talk to each other but without the need for logins, passwords and associated credit cards as it uses a secure authentication mechanism that combines Macaroons and the Lightning Network.More Info

    How to use our L402 service:

  • Request Access to the resource

    • Make your initial request to the service. You'll receive a 402 response with a header containing: A macaroon (like a ticket) An invoice (payment request)
    • www-authenticate: L402 macaroon="<macaroon>", invoice="<invoice>"
    • Pay the Lightning invoice to obtain the preimage
    • Once the payment is completed, send another POST request to https://sats4ai.com/api/l402/logo.png with the macaroon obtained in Step 1 and the Preimage from Step 2.
    • Authorization: L402 <macaroon>:<preimage>
    • The body data of both requests must be the same or the request after will fail
    • *This service is not returning as a Stream currently
  • Serve the resource