# webln.request()

➡️ This API is part of the upcoming [WebBTC](https://webbtc.dev/) spec.&#x20;

{% hint style="warning" %}
The available APIs heavily depend on the connector (LND, CLN, etc) that is used. You can use [`webln.getInfo`](/building-lightning-apps/webln-reference/webln.getinfo.md) to check for supported methods. (`methods`)&#x20;
{% endhint %}

#### Method

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

#### Response

See the API docs of the connector that is currently in use. (e.g. the [LND API](https://api.lightning.community/) or the [CLN API](https://lightning.readthedocs.io/))

#### Code Example (using LND) <a href="#demo" id="demo"></a>

<pre class="language-typescript"><code class="lang-typescript">await webln.enable();

// check if the connected node supports the required methods
<strong>const info = await webln.getInfo();
</strong><strong>if (!info.methods.includes("listpeers")) {
</strong><strong>  alert('Invalid node connection. Please use LND');
</strong><strong>}
</strong>// 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})
</code></pre>

#### Demos

* [Liquimercado ](https://replit.com/@getalby/liquimercado-core-lightning)(Core Lightning)
* [Liquimercado](https://replit.com/@getalby/liquimercado-lnd) (LND)
* [Boostagram viewer ](https://replit.com/@getalby/boostagram-viewer-LND#src/Home.tsx)(LND)

### Supported connectors

<table><thead><tr><th width="331">Connector</th><th align="center">🐝 Alby</th></tr></thead><tbody><tr><td><a href="https://lightning.readthedocs.io/">Core Lightning</a></td><td align="center">✅</td></tr><tr><td><a href="https://api.lightning.community/">LND</a></td><td align="center">✅</td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.webln.guide/building-lightning-apps/webln-reference/webln.request.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
