Skip to content

Local API

Drive Donut profiles with Playwright and Wayfern.

On this page

Two things have the Wayfern name:

  • Wayfern is the Chromium-based engine that runs every Donut profile. It sets the fingerprint (user agent, platform, timezone, language, WebGL, canvas, audio, WebRTC and more) in C++, inside the browser.
  • wayfern on npm is an open-source helper for Playwright, under the MIT license. It makes mouse movement, typing and scrolling human-like, and wraps the engine’s fingerprint commands.

You can use the npm package with any Playwright Chromium, and you can drive a Donut profile with plain Playwright or Puppeteer.

Install

npm install wayfern playwright

Attach to a Donut profile

Launch the profile with the local API (Pro, Team or Enterprise). The response has remote_debugging_port. Then connect:

// `wayfern` re-exports Playwright and humanizes every page.
import { chromium } from "wayfern";

const browser = await chromium.connectOverCDP(`http://127.0.0.1:${port}`);
const context = browser.contexts()[0];
const page = context.pages()[0] ?? (await context.newPage());

await page.goto("https://example.com");
await page.click("button#login");
await page.fill("input[name=email]", "[email protected]");

The profile already has its fingerprint, cookies and proxy. You do not need the fingerprint helpers with it. To stop the browser, call POST /v1/profiles/{id}/kill.

Wayfern accepts up to 100 automation (CDP) requests a minute on Pro, Team and Enterprise.

Puppeteer works the same way: puppeteer.connect({ browserURL: "http://127.0.0.1:" + port }).

Drop-in mode

Import chromium from wayfern in place of playwright. Existing Playwright code keeps working, and clicks, hovers, typing and wheel scrolls become human-like.

import { chromium } from "wayfern";

const browser = await chromium.launch();
const page = await browser.newPage();

await page.click("button");
await page.locator("input").hover();
await page.keyboard.type("hello world");
await page.mouse.wheel(0, 800);

Explicit mode

For typing speed, scroll targets and fingerprint commands, wrap a page:

import { chromium } from "playwright";
import { wayfern } from "wayfern";

const page = await (await chromium.launch()).newPage();
const wfp = wayfern(page);

await page.click("button"); // still humanized through hooks
await wfp.typeText("hello", { wpm: 90 });
await wfp.scrollTo("footer");

API

wfp.move(x, y, opts); // duration, overshoot (0 to 1)
wfp.hover(target, opts);
wfp.click(target, opts); // button, clickCount, delay, position, hoverPause
wfp.dblclick(target, opts);
wfp.clickAt(x, y, opts);
wfp.type(target, text, opts); // wpm, layout ('qwerty' | 'azerty'), errors, clear, focus
wfp.typeText(text, opts);
wfp.fillForm(values, opts); // {selector: value} or [[sel, val], …]; tabs between fields
wfp.scroll(dx, dy, opts);
wfp.scrollBy(dy, opts);
wfp.scrollTo(target, opts);
wfp.idle(ms, opts); // small cursor movements for ms
wfp.pause(min, max);
wfp.refreshFingerprint(params); // operatingSystem ('windows' | 'macos' | 'linux' | 'android' | 'ios'), timezone, language, latitude, longitude
wfp.getFingerprint(); // the fingerprint the engine reports
wfp.cdp.send(method, params); // any CDP command

refreshFingerprint and getFingerprint need the Wayfern engine. A click waits a moment over the target when the cursor moved far to reach it. Turn that off with { hoverPause: false }.

Turn humanization off

// One call
await page.click("button", { force: true });
await page.locator("input").hover({ trial: true });

// A whole page
const wfp = wayfern(page, { hooks: false });

// The pause before one click
await wfp.click("button", { hoverPause: false });

Checked against the app on .