nstbrowser-sdk-node v0.0.6
NST BROWSER NODE SDK
Nst browser node sdk
Installing
Using npm:
$ npm install nstbrowser-sdk-node
Using pnpm:
$ pnpm install nstbrowser-sdk-node
Using yarn:
$ yarn add nstbrowser-sdk-node
How To Use
javascript:
import { NstBrowser } from 'nstbrowser-sdk-node';
const nst = new NstBrowser('your api key', {
timeout: 60000,
apiAddress: 'http://localhost:8848/api/agent'
});
const { getLatestVersion } = nst.agentManager();
getLatestVersion();
typescript:
import { NstBrowser, NstBrowserTypes } from 'nstbrowser-sdk-node';
const nst: NstBrowserTypes = new NstBrowser('your api key', {
timeout: 60000,
apiAddress: 'http://localhost:8848/api/agent'
});
const { getLatestVersion } = nst.agentManager();
getLatestVersion();
NstBrowser Node Sdk Response Schema:
{
// `data` is the response
"data": {},
// `code` is the HTTP status code
"code": 200,
// `err` is the request's status
"err": false,
"msg": "success"
}
BrowserManager
forceStart
force start the browser by profileId
const { forceStart } = nst.browserManager();
forceStart(profileId: string);
start
start the browser by profileId
const { start } = nst.browserManager();
start(profileId: string);
startSome
batch start browser by profileIds
const { startSome } = nst.browserManager();
startSome(profileIds: string[]);
stop
stop the browser by profileId
const { stop } = nst.browserManager();
stop(profileId: string);
stopSome
batch stop browser by profileIds
const { stopSome } = nst.browserManager();
stopSome(profileIds: string[]);
stopAll
stop all running browser
const { stopAll } = nst.browserManager();
stopAll();
getRunningBrowserAll
get all running browser's info
const { getRunningBrowserAll } = nst.browserManager();
getRunningBrowserAll();
response data:
[
{
profileId: "string",
name: "string",
version: "string",
kernelType: "string", // nstchrome | nstfirefox
running: "boolean",
userDirPath: "string"
}
]
getRemoteWebSocketDebuggingURL
get browser remote web socket debugging url
const { getRemoteWebSocketDebuggingURL } = nst.browserManager();
getRemoteWebSocketDebuggingURL(profileId: string);
getProfilesStatus
get all profiles status
const { getProfilesStatus } = nst.browserManager();
getProfilesStatus();
ProfileManager
createProfile
create profile
const { createProfile } = nst.profileManager();
createProfile({
"deviceMemory": 2,
"groupId": "1e455935-3e3e-4e3e-8e3e-3e3e3e3e3e3e",
"hardwareConcurrency": 2,
"kernel": "chromium",
"kernelMilestone": "120",
"name": "Profile",
"platform": "windows",
"proxy": "http://username:password@ip:port",
"proxyGroupName": "ProxyGroup1"
});
response data:
{
"_id": "string",
"createdAt": "string",
"fingerprintId": "string",
"groupId": "string",
"kernel": 0,
"kernelMilestone": "string",
"kernelVersion": "string",
"name": "string",
"note": "string",
"platform": 0,
"platformVersion": "string",
"profileId": "string",
"saveLocal": true,
"status": 0,
"tags": [
"string"
],
"teamId": "string",
"uaFullVersion": "string",
"updatedAt": "string",
"userId": "string"
}
deleteProfile
delete profile by profileId
const { deleteProfile } = nst.profileManager();
deleteProfile(profileId: string);
profiles
list profiles
const { profiles } = nst.profileManager();
profiles({
page: 1,
pageSize: 10,
s: '',
groupId: ''
});
response data:
"data": {
"docs": [
{
"fingerprintId": "string",
"groupId": "string",
"kernel": 0,
"kernelMilestone": "string",
"kernelVersion": "string",
"name": "string",
"note": "string",
"platform": 0,
"platformVersion": "string",
"profileId": "string",
"proxyConfig": {
"checker": "string",
"host": "string",
"password": "string",
"port": "string",
"protocol": "string",
"proxySetting": "string",
"proxyType": "string",
"url": "string",
"username": "string"
},
"tags": [
"string"
],
"teamId": "string",
"uaFullVersion": "string",
"userId": "string"
}
],
"hasNextPage": true,
"hasPrevPage": true,
"limit": 0,
"nextPage": 0,
"offset": 0,
"page": 0,
"pagingCounter": 0,
"prevPage": 0,
"totalDocs": 0,
"totalPages": 0
}
batchUpdateProxy
batch update proxy for profiles, if proxy url is empty,you should set value to: protocol、host and port, otherwise set proxy url just fine.
const { batchUpdateProxy } = nst.profileManager();
batchUpdateProxy({
"profileIds": string[],
"proxyConfig": {
"checker": "string",
"host": "string",
"password": "string",
"port": "string",
"protocol": "string",
"proxySetting": "string",
"proxyType": "string",
"url": "string",
"username": "string"
}
});
CookieManager
clearCookies
Delete the cookies cached by the browser in the current computer environment.
const { clearCookies } = nst.cookieManager();
clearCookies(profileId);
Devtool
startedBrowser
start browser
const { startedBrowser } = nst.devtool();
startedBrowser(profileId: string);
response data:
{
"port": 0,
"webSocketDebuggerUrl": "string"
}
launchNewBrowser
launch new browser
const { launchNewBrowser } = nst.devtool();
launchNewBrowser(config: string);
response data:
{
"port": 0,
"webSocketDebuggerUrl": "string"
}
launchExistBrowser
launch exist browser
const { launchExistBrowser } = nst.devtool();
launchExistBrowser(profileId: string, {
'x-api-key': string,
config?: string,
});
response data:
{
"port": 0,
"webSocketDebuggerUrl": "string"
}
2 months ago
2 months ago
8 months ago
8 months ago
8 months ago
8 months ago
8 months ago
7 months ago
7 months ago
7 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago