Connect
GET
/connect/{profileId}Modified at:Â 6 days ago
::: warning Notice
Docker is standalone with Nstbrowser dashboard, please do not confuse the APIs between them.
:::
Start or Connect to a Browser Instance
Supported Request Methods:
1. WebSocket
- Supports connecting to a browser instance via WebSocket using tools that support CDP (Chrome DevTools Protocol), such as Puppeteer, Playwright, Chromedp, etc.
- When
profileId
isnull
or not specified, the system will launch a new browser instance. - If accessed via WebSocket, the browser instance will automatically close when the WebSocket connection is terminated.
- When
profileId
is notnull
, the system will connect to the already running browser instance associated with the specifiedprofileId
.
::: warning Warning
profileId must be obtained from the response of the Start Browser REST API.
:::
2. GET
- Supports retrieving or launching a browser instance's basic information via a GET request.
- When
profileId
isnull
or not specified, the system will launch a new browser instance and return its basic information. - When
profileId
is notnull
, it will return the corresponding browser instance information.
::: warning Warning
profileId must be obtained from the response of the Start Browser REST API.
:::
The GET request returns the following data format:
{
"data": {
"profileId": "33faafc7-b92a-4952-a835-334b6b27dff1",
"port": 42840,
"proxy": ""
},
"err": false,
"msg": "success",
"code": 200
}
Example Usage:
WebSocket Connection Example:
Example code for connecting using Puppeteer to the URL: ws://localhost:8848/connect
:
const puppeteer = require('puppeteer-core');
(async () => {
const config = {
"name": "testProfile",
"platform": "windows",
"kernel": "chromium",
"kernelMilestone": "128",
"proxy": "http://127.0.0.1:8000",
"fingerprint": {
"flags": {
"timezone": "BasedOnIp",
"screen": "Custom"
},
"screen": {
"width": 1000,
"height": 1000
},
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.6613.85 Safari/537.36"
},
"args": {
"--proxy-bypass-list": "*.nstbrowser.io"
}
}
try {
const query = new URLSearchParams({
config: JSON.stringify(config),
});
const browser = await puppeteer.connect({
browserWSEndpoint: `ws://127.0.0.1:8848/connect?${query}`
});
const page = await browser.newPage();
await page.goto('https://google.com');
// Perform actions...
await browser.close();
} catch (e) {
console.error(e)
}
})();
GET Request Example:
URL: http://localhost:8848/connect/{profileId}
curl http://localhost:8848/connect
Request
Path Params
profileId
stringÂ
required
the profileId to connect to, a browser will be launched with random config if not passed
Query Params
config
stringÂ
optional
launch config, in encoded json string, you can custom launch config if profileId not passed,the full config
refer to Start Browser REST API
Request samples
Responses
OK(200)
HTTP Code:Â 200
Content Type :Â JSONapplication/json
Data Schema
No schema defined
Example
Not configured
Modified at 6 days ago