> For the complete documentation index, see [llms.txt](https://www.webln.guide/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.webln.guide/building-lightning-apps/webln-reference/webln.request.md).

# 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
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
