0.0.10 • Published 4 months ago

nstbrowser-sdk-node v0.0.10

Weekly downloads
-
License
ISC
Repository
github
Last release
4 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();

Browserless:

import { Browserless } from 'nstbrowser-sdk-node';

const browserless = new Browserless({
  apiKey: 'your api key',
  proxy: 'your proxy', // required
})

browserless.load('https://nstbrowser.io').then(text => {
  
})

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

getRemoteDebuggingAddress

get browser remote web socket debugging url

const { getRemoteDebuggingAddress } = nst.browserManager();
getRemoteDebuggingAddress(profileId: string);

getProfilesStatus

get all profiles status

const { getProfilesStatus } = nst.browserManager();
getProfilesStatus();

ProfileManager

createProfile

create profile

Detail docs

const { createProfile } = nst.profileManager();
createProfile({
  "kernel": "chromium",
  "kernelMilestone": "120",
  "name": "Profile",
  "platform": "windows"
});

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"
  }
});

getProfileTags

get all profile tags

const { getProfileTags } = nst.profileManager();
getProfileTags();

response data:

[
  {
    color: "string",
    name: "string",
  }
]

batchUpdateProfileTags

batch update profile tags

const { batchUpdateProfileTags } = nst.profileManager();

batchUpdateProfileTags({
  "profileIds": string[],
  "tags": {
    "color": string;
    "name": string;
  }[]
});

batchCreateProfileTags

batch create profile tags

const { batchCreateProfileTags } = nst.profileManager();

batchCreateProfileTags({
  "profileIds": string[],
  "tags": {
    "color": string;
    "name": string;
  }[]
});

batchClearProfileTags

batch clear profile tags

const { batchClearProfileTags } = nst.profileManager();

batchClearProfileTags({
  "profileIds": ["string"]
});

clearCookies

clear local cookies by profileId

const { clearCookies } = nst.profileManager();
clearCookies("profileId")

clearProfileCache

clear user profile dir.

const { clearProfileCache } = nst.profileManager();
clearProfileCache("profileId")

batchClearProfileCache

batch clear user profile dir.

const { batchClearProfileCache } = nst.profileManager();
batchClearProfileCache(["profileId"])

Devtool

launchNewBrowser

launch new browser Detail docs

const { launchNewBrowser } = nst.devtool();
launchNewBrowser(config);

response data:

{
  "port": 0,
  "webSocketDebuggerUrl": "string"
}

launchExistBrowser

launch exist browser Detail docs

const { launchExistBrowser } = nst.devtool();
launchExistBrowser(profileId: string, {
	config?: string,
});

response data:

{
  "port": 0,
  "webSocketDebuggerUrl": "string"
}
0.0.10

4 months ago

0.0.9

8 months ago

0.0.8

11 months ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

1.0.26

2 years ago

1.0.25

2 years ago

1.0.24

2 years ago

1.0.23

2 years ago

0.0.1

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.4

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago