Skip to main content

Remote Browser Python SDK

Python client for the Remote Browser REST API, with a remotebrowser command-line tool.

Requires Python 3.11 or later. It has no dependencies and uses the standard library's urllib.

Installation

pip install remotebrowser

Usage

import os

from remotebrowser import RemoteBrowser

client = RemoteBrowser(
    api_key=os.environ["REMOTEBROWSER_API_KEY"],  # default, can be omitted
    base_url=os.environ["REMOTEBROWSER_URL"],  # default, can be omitted
)

config = {"os": "ubuntu-26.04", "browser": "chrome"}
browser_id = client.browsers.create(**config)["browser_id"]
browser = client.browsers.retrieve(browser_id)
print(browser["status"])  # 'starting' | 'running' | ...

Responses are plain dicts, typed with TypedDicts such as Browser and BrowserStatusResponse.

Connect with Playwright

from playwright.sync_api import sync_playwright

cdp_url = client.browsers.connect_url(browser_id)

with sync_playwright() as p:
    browser = p.chromium.connect_over_cdp(cdp_url, headers=client.auth_headers)
    context = browser.contexts[0]
    page = context.new_page()
    page.goto("https://example.com")
    page.screenshot(path="example.png")
    page.close()

Command-line tool

The package installs a remotebrowser executable, which can also run as python -m remotebrowser. It reads the same REMOTEBROWSER_API_KEY and REMOTEBROWSER_URL environment variables.

pipx install remotebrowser   # or: uvx remotebrowser <command>

ID=$(remotebrowser create --os ubuntu-26.04 --browser chrome --wait)
remotebrowser list
remotebrowser get $ID
remotebrowser connect $ID      # prints the CDP WebSocket URL
remotebrowser suspend $ID
remotebrowser resume $ID
remotebrowser config set $ID --proxy socks5://proxy.example:1080
remotebrowser config get $ID
remotebrowser delete $ID
Command Description
create [options] Launch a browser and print its id
list Print the ids of the starting and running browsers
get <id> Show the details of a browser
delete <id>... Terminate browsers
suspend <id>... / resume <id>... Suspend or resume browsers
connect <id> Print the CDP WebSocket URL
config get <id> Show the configuration
config set <id> --proxy <url> Change the proxy
config set <id> --no-proxy Remove the proxy

create takes --name, --description, --os, --browser, --screen-resolution, --screen-scale, --proxy, and --wait (wait until the browser is running). Every command takes --json to print the raw API response. Run remotebrowser --help, or remotebrowser <command> --help, for details.

The CDP endpoint needs the API key in the Authorization: Bearer header.

The exit code is 0 on success, 1 when the API call fails, and 2 for a usage error.

API

Method Endpoint
client.browsers.create(**params) POST /api/v1/browsers
client.browsers.list() GET /api/v1/browsers
client.browsers.retrieve(id) GET /api/v1/browsers/{id}
client.browsers.delete(id) DELETE /api/v1/browsers/{id}
client.browsers.suspend(id) POST /api/v1/browsers/{id}/suspend
client.browsers.resume(id) POST /api/v1/browsers/{id}/resume
client.browsers.config.retrieve(id) GET /api/v1/browsers/{id}/config
client.browsers.config.update(id, proxy=...) PATCH /api/v1/browsers/{id}/config
client.browsers.connect_url(id) WebSocket URL for CDP

create takes the keyword arguments name, description, os, browser, screen_resolution, screen_scale, and proxy. Each one left out takes the server's default. config.update takes proxy=None to connect directly again.

Every method also takes the request options timeout (seconds), max_retries, and extra_headers as keyword arguments.

client.browsers.list(timeout=5)

Handling errors

Failed requests raise a subclass of APIError, which has status, body (the parsed response body), and headers.

import remotebrowser

try:
    client.browsers.resume(browser_id)
except remotebrowser.ConflictError as err:
    print("Browser is", err.body["status"])
Status code Error type
400 BadRequestError
401 AuthenticationError
403 PermissionDeniedError
404 NotFoundError
409 ConflictError
422 UnprocessableEntityError
429 RateLimitError
>=500 InternalServerError
N/A APIConnectionError

A timeout raises APIConnectionTimeoutError. A missing API key or base URL raises RemoteBrowserError, the base class of all of them.

Retries and timeouts

Connection errors, 408, 429, and 5xx responses are retried 2 times by default, with exponential backoff. The Retry-After header is respected. 409 is not retried because it means the browser is in the wrong state.

Each request times out after 60 seconds without a response by default.

client = RemoteBrowser(max_retries=0, timeout=20)

Metadata

Release files for remotebrowser 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for remotebrowser 0.2.0
File Size Uploaded Provenance Actions
remotebrowser-0.2.0.tar.gz 20.0 kB Without provenance Details for remotebrowser-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for remotebrowser 0.2.0
File Interpreter ABI Platform Actions
remotebrowser-0.2.0-py3-none-any.whl Python 3 none any Details for remotebrowser-0.2.0-py3-none-any.whl

Total release size: 33.7 kB

Release files / remotebrowser-0.2.0.tar.gz

Download URL remotebrowser-0.2.0.tar.gz
Size 20.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a25dd84311c3a708e43db8e9f3e91027a74eb9999677282cc568d864c59ee72d
BLAKE2b-256 checksum
How to use checksums
8a4da25f0e1f942dee7cbe63e7e27dcbf3a9d209e81f5a595993a2784d2df848
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / remotebrowser-0.2.0-py3-none-any.whl

Download URL remotebrowser-0.2.0-py3-none-any.whl
Size 13.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
726d61bac0e05683a62c379eed7c3cfc5d5a069fc4d8c8ca43ed35e70f10bb29
BLAKE2b-256 checksum
How to use checksums
05bbdfcf773b2a2886e6a6316f0328c743df49f39b34d3aad556d19192c9ef86
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.32 {"installer":{"name":"uv","version":"0.11.32","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Fedora Linux","version":"44","id":"","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for remotebrowser 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page