# nstbrowser-sdk-node

> nst browser node sdk

Latest version **0.1.1** (published 2025-04-07) · ISC license · 0 weekly downloads

## Install

```sh
npm install nstbrowser-sdk-node
pnpm add nstbrowser-sdk-node
yarn add nstbrowser-sdk-node
bun add nstbrowser-sdk-node
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; large bundle; pre 1.0.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2025-04-07 |
| First published | 2023-09-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 4 |
| Unpacked size | 29.7 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | nstbrowser |
| Maintainers | nstbrowser |
| Keywords | nstbrowser, nstbrowser-sdk, nstbrowser-sdk-node, nst, nst-sdk, nst-sdk-node, nstlabs |

## Links

- npm: https://www.npmjs.com/package/nstbrowser-sdk-node
- Repository: https://github.com/NSTBrowser/nstbrowser-sdk-node
- Homepage: https://www.nstbrowser.io
- Issues: https://github.com/NSTBrowser/nstbrowser-sdk-node/issues
- npm.io page: https://npm.io/package/nstbrowser-sdk-node

## Dependencies (4)

- [axios](https://npm.io/package/axios.md) ^1.7.7
- [form-data](https://npm.io/package/form-data.md) ^4.0.1
- [puppeteer-core](https://npm.io/package/puppeteer-core.md) 23.3.0
- [@rollup/plugin-replace](https://npm.io/package/@rollup/plugin-replace.md) ^5.0.7

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 0.1.1 (latest) — 2025-04-07
- 0.1.0 — 2025-03-28
- 0.0.10 — 2025-02-26
- 0.0.9 — 2024-11-01
- 0.0.8 — 2024-08-08
- 0.0.7 — 2024-07-04
- 0.0.6 — 2024-03-08
- 0.0.5 — 2024-03-07
- 0.0.4 — 2023-10-20
- 0.0.3 — 2023-10-09
- 0.0.2 — 2023-10-09
- 0.0.1 — 2023-09-25

## README

# Nstbrowser SDK for Node.js

A Node.js SDK for interacting with [Nstbrowser API v2](https://apidocs.nstbrowser.io/)

> **Note**: This documentation is for API v2, which is the recommended version with complete functionality from v1 plus additional features. For v1 documentation, please refer to [README-v1.md](./README-v1.md). New users are encouraged to use v2 for a more stable and standardized experience.

## Overview

This SDK implements Nstbrowser API v2, providing a comprehensive set of tools for managing browser profiles, controlling browser instances, managing local browser data, and utilizing Chrome DevTools Protocol (CDP) for browser automation.

The SDK enables you to:
- Create and manage browser profiles with detailed fingerprint configurations
- Start and stop browser instances individually or in batch
- Configure and manage proxies for profiles
- Manage profile tags for better organization
- Clear browser cache and cookies
- Connect to browsers using Chrome DevTools Protocol (CDP)
- Automate browser actions through CDP integration with Puppeteer

## Installation

Using npm:

```bash
$ npm install nstbrowser-sdk-node
```

Using pnpm:

```bash
$ pnpm install nstbrowser-sdk-node
```

Using yarn:

```bash
$ yarn add nstbrowser-sdk-node
```

## Getting Started

To use the SDK, you need an API key from Nstbrowser:

```javascript
import { NstBrowserV2 } from 'nstbrowser-sdk-node';

// Initialize the client with your API key
const client = new NstBrowserV2('your_api_key', {
  timeout: 60000,
  apiAddress: 'http://localhost:8848/api/v2'
});

// Now you can use the various services
const profileId = 'your_profile_id';

// Start a browser instance
const startResponse = await client.browsers().startBrowser({ profileId });
console.log('Browser started:', startResponse);

// Stop the browser instance
const stopResponse = await client.browsers().stopBrowser({ profileId });
console.log('Browser stopped:', stopResponse);
```

## CDP Integration with Puppeteer

One of the most powerful features of the SDK is its seamless integration with Puppeteer for browser automation:

```javascript
import { NstBrowserV2 } from 'nstbrowser-sdk-node';
import puppeteer from 'puppeteer-core';

async function automateWithPuppeteer() {
  const client = new NstBrowserV2('your_api_key');
  
  // Connect to a browser using CDP
  const cdpResponse = await client.cdpEndpoints().connectBrowser({
    profileId: 'your_profile_id',
    config: {
      headless: false,
      autoClose: false
    }
  });

  // Connect Puppeteer to the browser instance
  const browser = await puppeteer.connect({
    browserWSEndpoint: cdpResponse.data.webSocketDebuggerUrl,
    defaultViewport: null
  });

  // Use Puppeteer for automation
  const page = await browser.newPage();
  await page.goto('https://example.com');
  
  // ... perform other actions
}
```

## Examples

The SDK comes with a comprehensive set of examples in the `/examples/v2` directory. To run the examples:

1. Navigate to the examples directory and install dependencies:
```bash
cd examples/v2
npm install
```

2. Create a `.env` file in the `examples/v2` directory and add your API key:
```bash
echo "nstbrowser_api_key=your-api-key" > .env
```

3. Run any example:
```bash
node browsers/startBrowser.js
```

Available examples are organized by service:

### Browser Examples
- `browsers/getBrowserDebugger.js`: Get browser debugger information for automation
- `browsers/getBrowserPages.js`: Get information about browser pages
- `browsers/getBrowsers.js`: Get list of active browsers with status information
- `browsers/startBrowser.js`: Start a browser for a specific profile
- `browsers/startBrowsers.js`: Start multiple browsers in batch
- `browsers/startOnceBrowser.js`: Start a once-off browser with custom configuration
- `browsers/stopBrowser.js`: Stop a specific browser instance
- `browsers/stopBrowsers.js`: Stop multiple browser instances in batch

### Profile Examples
- `profiles/batchClearProfileTags.js`: Clear tags for multiple profiles in batch
- `profiles/batchCreateProfileTags.js`: Create tags for multiple profiles in batch
- `profiles/batchResetProfileProxy.js`: Reset proxies for multiple profiles in batch
- `profiles/batchUpdateProfileTags.js`: Update tags for multiple profiles in batch
- `profiles/batchUpdateProxy.js`: Update proxies for multiple profiles in batch
- `profiles/clearProfileTags.js`: Clear all tags from a specific profile
- `profiles/createProfile.js`: Create a new profile with detailed configuration
- `profiles/createProfileTags.js`: Create new tags for a specific profile
- `profiles/deleteProfile.js`: Delete a specific profile
- `profiles/deleteProfiles.js`: Delete multiple profiles in batch
- `profiles/getProfileTags.js`: Get all tags associated with profiles
- `profiles/getProfiles.js`: Get profiles with filtering options
- `profiles/resetProfileProxy.js`: Reset proxy configuration for a specific profile
- `profiles/updateProfileProxy.js`: Update proxy configuration for a specific profile
- `profiles/updateProfileTags.js`: Update tags for a specific profile
- `profiles/getAllProfileGroups.js`: Get all profile groups
- `profiles/changeProfileGroup.js`: Change a profile group
- `profiles/batchChangeProfileGroup.js`: Batch changes to profile groups

### Local Data Examples
- `locals/clearProfileCache.js`: Clear browser cache for a specific profile
- `locals/clearProfileCookies.js`: Clear browser cookies for a specific profile

### CDP Endpoint Examples
- `cdpEndpoints/connectBrowser.js`: Connect to a browser using CDP and automate with Puppeteer
- `cdpEndpoints/connectOnceBrowser.js`: Connect to a once-off browser with CDP and automate with Puppeteer

## Support

For support, feel free to reach out to us via [Discord](https://api.nstbrowser.io/api/v1/links/discord). For more detailed documentation, visit the official Nstbrowser documentation: [Nstbrowser API Documentation](https://apidocs.nstbrowser.io).

---
_Source: https://npm.io/package/nstbrowser-sdk-node · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
