Contents

Playwright and Puppeteer

Local API starts the browser; CDP connects your script to it. The examples below use the launch response and the existing profile context, so cookies and settings stay in place.

Updated: 3 min read

The manager reference covers retired releases. The local manager has no published installer. Profile manager status

On this page

Install a client

You need Node.js 18 or newer for the built-in fetch. Install Playwright if you plan to use it, or puppeteer-core if you plan to use Puppeteer. puppeteer-core does not download another browser; the script connects to the Chromium build that Ombra started.

Install a client
npm install playwright
# or
npm install puppeteer-core

The script does not launch its own browser. It calls Local API, receives the WebSocket address, and connects to the browser that already has the profile cookies, proxy and fingerprint.

Complete Node.js example

Save the script as example.mjs. With no argument it prints profile IDs; with a profile ID it starts the profile, connects over CDP, opens example.com, prints the title and stops the profile in a finally block. The list call uses page and page_size; the start and stop calls use the same helper.

example.mjs
import { chromium } from 'playwright';

const base = 'http://127.0.0.1:45678';
const profileId = process.argv[2];

async function api(method, body = {}) {
  const response = await fetch(base + '/api/v2/browser-profile/' + method, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(body),
  });
  if (!response.ok) throw new Error('Local API: HTTP ' + response.status);
  const result = await response.json();
  if (result.code !== 0) throw new Error(result.msg || 'Local API error');
  return result.data;
}

if (!profileId) {
  const data = await api('list', { page: 1, page_size: 100 });
  console.table(data.list.map(p => ({ id: p.profile_id, name: p.name })));
  console.log('Run again with a profile ID: node example.mjs PROFILE_ID');
} else {
  const state = await api('active', { profile_id: profileId });
  if (state.status === 'Active') {
    throw new Error('Choose a stopped profile for this example');
  }
  const data = await api('start', { profile_id: profileId });
  try {
    const browser = await chromium.connectOverCDP(data.ws.puppeteer);
    const context = browser.contexts()[0];
    if (!context) throw new Error('Profile context not found');
    const page = await context.newPage();
    await page.goto('https://example.com');
    console.log(await page.title());
  } finally {
    await api('stop', { profile_id: profileId });
  }
}

Run the list first, then repeat the command with a real ID: node example.mjs YOUR_PROFILE_ID. The script prints the page title and stops the profile even if navigation or the title check fails.

Playwright

chromium.connectOverCDP(data.ws.puppeteer) returns the running browser. Use browser.contexts()[0]; this is the profile context with its cookies and storage. Then call context.newPage() and navigate.

Playwright connection
const browser = await chromium.connectOverCDP(data.ws.puppeteer);
const context = browser.contexts()[0];
const page = await context.newPage();
await page.goto('https://example.com');

Do not call chromium.launch() or browser.newContext(). A new context would not carry the profile cookies, and a separate browser would not use the profile fingerprint or proxy.

Puppeteer

puppeteer.connect({ browserWSEndpoint: data.ws.puppeteer }) connects to the same browser. Use browser.pages() to get the open pages; the profile may already have one. Create a page only when the list is empty.

Puppeteer connection
import puppeteer from 'puppeteer-core';

// data is the response from the start call
const browser = await puppeteer.connect({
  browserWSEndpoint: data.ws.puppeteer,
});
const pages = await browser.pages();
const page = pages[0] || await browser.newPage();
await page.goto('https://example.com');
console.log(await page.title());

Use the profile context

Work in the existing context and close the pages you create. The CDP endpoint stays valid while the browser is running. If the script closes the last page, the browser may exit; stop the profile explicitly when the work is done. Use page.waitForLoadState() or a selector when the next action depends on the page.

For long tasks, check state.status before launch and use a timeout around navigation. A page that never finishes loading should not keep the profile slot occupied for the rest of the day.

Stop the profile

Call the stop method in a finally block so a failed assertion or a closed page does not leave the profile running. The full example above does this. If the process is killed before the call, stop the profile in the manager or wait for the manager to confirm the end of the process. Calling browser.close() also closes the browser, but the explicit stop call is easier to retry and log.

More about launch data and state checks: Launch and stop a profile. For connection errors, see Errors and troubleshooting.

Was this page helpful?

Tell us what to improve

Last updated:

OMBRA / APPLICATION INTERFACE

Application screenshot

Ombra interface with sample data. Select 1:1 to view the screenshot at its original size.