# Get

The following example demonstrates how to request a browser instance, navigate to a webpage, disconnect the browser, retrieve details about all active browsers, and close them.

```javascript
const svc = new BrowserService(cloudBrowserToken);

const rp = await svc.open();

if (rp.status !== ResponseStatus.SUCCESS || rp.address == null) {
    console.log(`Error requesting browser: ${rp.status}`);
    return;
}
console.log("Browser requested");

const browser = await puppeteer.connect({
    browserWSEndpoint: rp.address,
    defaultViewport: null,
    slowMo: 0,
});
console.log("Browser connected");

const page = (await browser.pages())[0];
await page.goto("http://www.cloudbrowser.ai");
console.log("Web visited");

browser.disconnect();
console.log("Browser disconnected");

const rpGet = await svc.get();

console.log("Label | Address | Started On | VNC Opened | VNC Pass");
for (const b of rpGet.browsers) {
    console.log(
        `${b.label} | ${b.address} | ${b.startedOn} | ${b.vncPass !== null} | ${b.vncPass}`
    );
    await svc.close(b.address);
}
```

***

#### F**ull example**

{% embed url="<https://github.com/CloudBrowser-AI/CloudBrowserAiNodeJS/blob/main/samples/get-close/src/index.ts>" %}

The `svc.get()` method is crucial for managing and monitoring active browser sessions. Here's why it's important:

1. **Session Retrieval:** It provides a list of all currently active browser sessions, enabling visibility into ongoing operations.
2. **Detailed Insights:** Each session includes metadata like:
   * **Label:** Identifies the session for organization.
   * **Address:** The WebSocket endpoint to reconnect if needed.
   * **Started On:** Tracks when the session was initiated.
   * **VNC Status and Password:** Indicates whether a remote desktop (VNC) is active and provides access credentials.
3. **Session Cleanup:** By iterating through the retrieved sessions, you can close inactive or unneeded sessions, freeing up resources and preventing unnecessary costs.

In this script, `svc.get()` ensures that no orphaned browser sessions remain by listing all active sessions and systematically closing them.


---

# 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://cloudbrowser.gitbook.io/docs/libraries/node.js-client/get.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.
