Connecting with other CDP clients
BrowserCat supports all client libraries based on Chrome Devtools Protocol (CDP). While we recommend sticking to Playwright or Puppeteer for their functionality and completeness, there’s no reason you must do so.
This article will guide you through connecting with you favorite CDP client.
Prerequisites
Before you get started, you’ll need to:
- Sign up for a free BrowserCat account.
- Create an API key.
- Install your favorite CDP client.
Make a connection
BrowserCat’s browser fleet is accessible via a WebSocket connection at wss://api.browsercat.com/connect
.
You’ll need to supply an API key, either through the “Api-Key” header or through the apiKey
query param.
The following code snippet shows how to create a raw websocket connection. It is NOT an efficient way to work with our browsers. Please choose a higher-level CDP client instead.
import {WebSocket} from 'ws';
const bcatUrl = new URL('wss://api.browsercat.com/connect');
// EITHER set the apiKey query param
bcatUrl.searchParams.set('apiKey', '<YOUR_API_KEY>');
// OR set the Api-Key header
const headers = {'Api-Key': '<YOUR_API_KEY>'};
// LAUNCH
const ws = new WebSocket(bcatUrl.href, {headers});
Configure the browser
It’s really easy to configure our browsers for your needs. Whether you want to connect to a specific region, set up a third-party proxy, or customize your browser launch args, we’ve got you covered.
See out browser config docs for more info.