0.0.6 • Published 2 months ago

nstbrowser-sdk-node v0.0.6

Weekly downloads
-
License
ISC
Repository
github
Last release
2 months ago

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"
}
0.0.6

2 months ago

0.0.5

2 months ago

1.0.26

8 months ago

1.0.25

8 months ago

1.0.24

8 months ago

1.0.23

8 months ago

0.0.1

8 months ago

0.0.3

7 months ago

0.0.2

7 months ago

0.0.4

7 months ago

1.0.22

9 months ago

1.0.21

9 months ago

1.0.20

9 months ago

1.0.19

9 months ago

1.0.18

9 months ago

1.0.17

9 months ago

1.0.16

9 months ago

1.0.15

9 months ago

1.0.14

9 months ago

1.0.13

9 months ago

1.0.12

9 months ago

1.0.11

9 months ago

1.0.10

9 months ago

1.0.9

9 months ago

1.0.8

9 months ago

1.0.6

9 months ago

1.0.5

9 months ago

1.0.4

9 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago

1.0.0

9 months ago