⚡
WebLN Guide
  • Introduction
    • 👋Welcome
    • â„šī¸What is WebLN
    • 🏅Benefits of WebLN
  • Building Lightning Apps
    • 👨‍đŸ’ģ👨đŸ’ģ Getting Started
    • đŸ’ģWebLN Reference
      • 🆕webln.isEnabled()
      • webln.enable()
      • webln.getInfo()
      • webln.keysend()
      • webln.makeInvoice()
      • webln.sendPayment()
      • 🆕webln.sendPaymentAsync()
      • webln.signMessage()
      • webln.verifyMessage()
      • 🆕webln.request()
      • 🆕webln.lnurl()
      • 🆕webln.on()
      • 🆕webln.off()
      • 🆕webln.getBalance()
      • Error handling
    • đŸ› ī¸Libraries and Tools
    • 🔆Best Practices
  • Ressources
    • ⚡WebLN Providers
    • 🚀Showcases
    • 👩‍đŸĢTutorials
    • 🌐Additional Resources
  • Contribute
    • đŸ—ī¸Working Group & Guidelines
    • 📖Glossary
Powered by GitBook
On this page
Edit on GitHub
  1. Building Lightning Apps
  2. WebLN Reference

webln.request()

A generic API to leverage the full potential of your connected node. Use any API node provides.

Last updated 1 year ago

âžĄī¸ This API is part of the upcoming spec.

The available APIs heavily depend on the connector (LND, CLN, etc) that is used. You can use to check for supported methods. (methods)

Method

async function request(method: string, params: Object): RequestResponse;

Response

See the API docs of the connector that is currently in use. (e.g. the or the )

Code Example (using LND)

await webln.enable();

// check if the connected node supports the required methods
const info = await webln.getInfo();
if (!info.methods.includes("listpeers")) {
  alert('Invalid node connection. Please use LND');
}
// list all connected peers
await webln.request("listpeers");
// response: 
{ peers: [
  address: "85.128.153.40:9735",
  bytes_recv: "23275891"
  bytes_sent: "519238"
  ... see LND API: https://api.lightning.community/#lnrpc-peer
]}

// connect to a new peer
const pubkey = "02af02be7c7e5cf...";
const host = "152.82.72.42:9735";
await webln.request('connectpeer', { addr: {host, pubkey }, perm: true})

Demos

Supported connectors

Connector
🐝 Alby

✅

✅

(Core Lightning)

(LND)

(LND)

đŸ’ģ
🆕
WebBTC
webln.getInfo
LND API
CLN API
Liquimercado
Liquimercado
Boostagram viewer
Core Lightning
LND