Skip to main content
View on GitHub
View on NPM

Installation

Install the Hyperbrowser SDK via npm or yarn:

Quick Start

Initialize the client with your API key:

Configuration Options

TypeScript Support

The SDK is fully typed with TypeScript. Import types from @hyperbrowser/sdk/types:

WebMCP page tools

Create a session with enableWebMcp: true to discover and invoke tools exposed by its pages. WebMCP is disabled by default. Navigate to a page that registers tools before discovery. See the WebMCP guide for complete examples. Invocation params contain toolRef, optional input (a JSON object), and optional timeoutSeconds. Pending handles have status running or awaiting_submission; continue result retrieval until terminal. Invocations are not automatically retried, and cancellation does not roll back side effects. Rediscover tools after navigation. Handles are ephemeral and terminal results expire after 10 minutes or earlier eviction. WebMCP request and response types are exported from @hyperbrowser/sdk/types.

Sandboxes

Sandbox APIs work in two layers. Sandbox control methods use your API key to create, inspect, connect to, and stop sandboxes. When you create or connect to a sandbox, the SDK also retrieves a sandbox-scoped runtime token and returns an authenticated SandboxHandle. Sandbox VM operations run inside that started sandbox and use the runtime token on the handle automatically. The SDK handles runtime token refreshes for you, so once you have a running SandboxHandle, you can call files, processes, terminal, networking, and snapshot methods without managing runtime auth yourself.

Sandbox Control

Use these methods to inspect existing sandboxes and discover reusable sandbox resources.

Details

List Sandboxes

List Images

List Snapshots

Get Sandbox Info

Lifecycle

Use these methods to create, connect to, and stop sandbox instances.

Create Sandbox

Use client.sandboxes.create(...) to start a sandbox from an image.

Start From A Snapshot

Start a new sandbox from a memory checkpoint.

Connect To A Running Sandbox

Use connect(...) to re-authenticate a running sandbox, refresh its runtime token, and return a SandboxHandle for runtime operations. If you already have a handle, call sandbox.connect() to re-authenticate it in place.

Stop Sandbox

Sandbox VM Operations

These methods operate on the sandbox VM itself when the sandbox is running.

Networking

Expose Port

Unexpose Port

Get Exposed URL

Processes

Run A Command

Use sandbox.exec(...) for one-shot commands. You can also pass a plain string like await sandbox.exec("node -v"). Commands are executed through /bin/sh -lc.
If stdout contains JSON, parse it explicitly:

Start A Process

Use sandbox.processes.start(...) for long-running processes.

Get A Process

List Processes

Write Process Stdin

Files

Read Text File

Write Text File

List Files

Watch A Directory

Create Upload URL

Create Download URL

Terminal

Create A Terminal

Use sandbox.terminal.create(...) or the alias sandbox.pty.create(...).

Get A Terminal

Snapshots

Create A Memory Snapshot

Sandbox guides:

Session Runtime Updates

Use session update helpers to change supported settings on an active browser without recreating it.

CAPTCHA Solving

solverType: "visual" enables the visual reCAPTCHA solver. Omit solverType to use the default automatic CAPTCHA solver configuration.

Manual CAPTCHA Evaluation

Supported captcha and captchaType values are turnstile, cloudflare-challenge, aliexpress, recaptcha, and amazon.

Integration Examples

Computer Actions

Programmatically control the browser with low-level actions. For the session-id parameter, you can also just pass in the detailed session object itself, and it is actually recommended to do so. Cursor position, current-cursor helpers, and modifier keys require version 1.1.0+. Click, drag, and scroll accept an optional trailing keys array of xdotool key names held during the action and released afterward. Omit it for an unmodified action. See Computer Actions for screen coordinates and cURL examples.

Cursor Position

Returns the shared ComputerActionResponse. Check that data contains coordinates before reading them. Pass true as the second argument to include a screenshot.

Click

Click at the Current Cursor

click() still requires x and y. Use clickAtCursor() to click without moving the pointer. It accepts the same optional button, click count, screenshot flag, and modifier keys after the session argument.

Type Text

Press Keys

Uses the xdotool format for keys: https://github.com/sickcodes/xdotool-gui/blob/master/key_list.csv

Move Mouse

Drag

Scroll

scroll() still requires coordinates and both deltas. It moves the pointer to (x, y) before scrolling.

Scroll at the Current Cursor

scrollAtCursor() scrolls without moving the pointer. The horizontal and vertical deltas default to zero, so pass a nonzero delta to scroll. The screenshot flag and modifier keys remain optional.

Screenshot

Support