REST APIs
::: warning Notice
Docker is standalone with Nstbrowser dashboard, please do not confuse the APIs between them.
:::
JavaScript fetch:
Launch browser
GET http://127.0.0.1:8848/browser/launch
Launch a browser by config, the full config
refer to LaunchNewBrowser.
The fingerprint.kernelMilestone
parameter is fixed value 120 for now.
async function startBrowser() {
let config = {
remoteDebuggingPort: 9223,
once: true,
headless: false,
autoClose: false,
fingerprint: {
name: 'testProfile',
kernel: 'chromium',
platform: 'linux',
kernelMilestone: '120', // fixed value: 120
hardwareConcurrency: 8,
deviceMemory: 8,
},
};
const configQuery = encodeURIComponent(JSON.stringify(config));
const response = await fetch(`http://127.0.0.1:8848/browser/launch?config=${configQuery}`, {
method: 'GET',
headers: {'Content-Type': 'application/json'},
});
const responseJson = await response.json();
return responseJson;
}
Running browsers
GET http://127.0.0.1:8848/browser/running
Get all running browsers
async function runningBrowsers() {
const response = await fetch(`http://127.0.0.1:8848/browser/running`, {
method: 'GET',
headers: {'Content-Type': 'application/json'},
});
console.log("response: ", responseJson);
}
Stop browser
GET http://127.0.0.1:8848/browser/stop/${profileId}
Stop browser by profileId
export async function stopBrowser(profileId: string): Promise<void> {
await fetch(`http://127.0.0.1:8848/browser/stop/${profileId}`, {
method: "GET",
headers: {"Content-Type": "application/json"},
});
}
Stop all browsers
GET http://127.0.0.1:8848/browser/stopAll
Stop all browsers
export async function stopAllBrowsers(): Promise<void> {
await fetch(`http://127.0.0.1:8848/browser/stopAll`, {
method: "GET",
headers: {"Content-Type": "application/json"},
});
}
Curl:
Launch browser
GET http://127.0.0.1:8848/browser/launch
Launch a browser by config
curl 'http://127.0.0.1:8848/browser/launch?config=%7B%22remoteDebuggingPort%22%3A9223%2C%22once%22%3Atrue%2C%22headless%22%3Afalse%2C%22autoClose%22%3Afalse%2C%22fingerprint%22%3A%7B%22name%22%3A%22testProfile%22%2C%22kernel%22%3A%22chromium%22%2C%22platform%22%3A%22windows%22%2C%22kernelMilestone%22%3A%22120%22%2C%22hardwareConcurrency%22%3A8%2C%22deviceMemory%22%3A8%7D%2C%22args%22%3A%7B%7D%7D' \
-H 'Accept: */*' \
-H 'Accept-Language: en-GB,en;q=0.9,zh-CN;q=0.8,zh;q=0.7' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/json' \
-H 'Pragma: no-cache' \
-H 'Sec-Fetch-Dest: empty' \
-H 'Sec-Fetch-Mode: cors' \
-H 'Sec-Fetch-Site: none' \
-H 'sec-ch-ua-mobile: ?0'
Running browsers
GET http://127.0.0.1:8848/browser/running
Get all running browsers
curl 'http://127.0.0.1:8848/browser/running' \
-H 'Accept: */*' \
-H 'Accept-Language: en-GB,en;q=0.9,zh-CN;q=0.8,zh;q=0.7' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/json' \
-H 'Pragma: no-cache' \
-H 'Sec-Fetch-Dest: empty' \
-H 'Sec-Fetch-Mode: cors' \
-H 'Sec-Fetch-Site: none' \
-H 'sec-ch-ua-mobile: ?0'
Stop browser
GET http://127.0.0.1:8848/browser/stop/${profileId}
Stop browser by profileId
curl 'http://127.0.0.1:8848/browser/stop/${profileId}' \
-H 'Accept: */*' \
-H 'Accept-Language: en-GB,en;q=0.9,zh-CN;q=0.8,zh;q=0.7' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/json' \
-H 'Pragma: no-cache' \
-H 'Sec-Fetch-Dest: empty' \
-H 'Sec-Fetch-Mode: cors' \
-H 'Sec-Fetch-Site: none' \
-H 'sec-ch-ua-mobile: ?0'
Stop all browsers
GET http://127.0.0.1:8848/browser/stopAll
Stop all browsers
curl 'http://127.0.0.1:8848/browser/stopAll' \
-H 'Accept: */*' \
-H 'Accept-Language: en-GB,en;q=0.9,zh-CN;q=0.8,zh;q=0.7' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/json' \
-H 'Pragma: no-cache' \
-H 'Sec-Fetch-Dest: empty' \
-H 'Sec-Fetch-Mode: cors' \
-H 'Sec-Fetch-Site: none' \
-H 'sec-ch-ua-mobile: ?0'