1

Fetch API Key

In Anchor UI, copy your API key

2

Install playwright

npm i playwright-core
3

Run sample code

If you don’t have access to code running, consider using the live playground

The following example demonstrates how to start the browser

import { chromium } from "playwright-core";

const browserSession = await chromium.connectOverCDP(`wss://connect.anchorbrowser.io?apiKey=ANCHOR-API-KEY`);
// Perform actions with `browser` as needed

4

Alter the browser configuration

Anchor Browser supports different configurations of the browser session, such as network configuration, identity profiles, termination and more.

To use a browser with a sepecific configuration, first create a browser session with the desired configuration, then connect to the session using the session URL.

import { chromium } from "playwright-core";

const response = await fetch("https://api.anchorbrowser.io/api/sessions", {
  method: "POST",
  headers: {
    "anchor-api-key": ANCHOR_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify(browserConfiguration),
});

const json = await response.json();
const { id } = json;

const browser = await chromium.connectOverCDP(`wss://connect.anchorbrowser.io?apiKey=${ANCHOR_API_KEY}&sessionId=${id}`);