npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

anchorbrowser

v1.0.0

Published

The official TypeScript library for the Anchorbrowser API

Readme

Anchorbrowser TypeScript API Library

NPM version npm bundle size

This library provides convenient access to the Anchorbrowser REST API from server-side TypeScript or JavaScript.

The REST API documentation can be found on docs.anchorbrowser.io. The SDK is generated directly from the public OpenAPI specification — every documented endpoint is available as a typed method.

Upgrading from v0.X.X? See MIGRATION.md for every breaking change and its v1 equivalent.

Installation

npm install anchorbrowser

Usage

import { client, Sessions } from 'anchorbrowser';

// The API key is read from the ANCHORBROWSER_API_KEY environment variable
// by default; set it explicitly like this:
client.setConfig({ auth: () => 'your-api-key' });

const session = await Sessions.createSession({
  body: { session: { recording: { active: true } } },
});
console.log(session.data);

Every resource is a class of static methods, one per API operation:

| Class | Operations | | ------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | | Sessions | create/list/get/delete sessions, screenshots, uploads, OS-level control (mouse, keyboard, clipboard, goto, scroll) | | Tools | performWebTask, fetchWebpage, screenshotWebpage, executeCode, createPagePdf | | Profiles, Identities, Applications | profile & identity management | | Webhooks | webhook CRUD, secret rotation, test events | | BatchSessions, Certificates, Integrations, Extensions | platform resources | | Tasks, TasksLegacy | task execution (v2) and the legacy v1 task API | | Recordings, Agent, Events, Billing | recordings, agent files & interventions, event signaling, billing info |

Methods take a single options object with path, query and body keys matching the OpenAPI operation, and return the parsed response body. Failures (non-2xx, network) throw.

import { Sessions, Webhooks } from 'anchorbrowser';

const session = await Sessions.createSession({
  body: { session: { recording: { active: true } } },
});

await Sessions.goto({
  path: { sessionId: session.data.id },
  body: { url: 'https://example.com' },
});

const hooks = await Webhooks.listWebhooks();

Playwright helpers

import { createBrowser, connectBrowser } from 'anchorbrowser';

// create a session and connect Playwright Chromium over CDP
const { browser, session } = await createBrowser({
  sessionOptions: { session: { recording: { active: true } } },
});
const page = browser.contexts()[0].pages()[0];
await page.goto('https://example.com');
await browser.close();

AI agent tasks

import { agentTask } from 'anchorbrowser';

const result = await agentTask('Find the current weather in Tokyo', {
  taskOptions: {
    url: 'https://weather.com',
    onAgentStep: (step) => console.log(step),
  },
});
console.log(result.data.result);

Error handling

Failures throw a typed error — check instanceof to branch on the failure kind, or read .status/.error for the raw response:

import { Sessions, NotFoundError, APIError } from 'anchorbrowser';

try {
  await Sessions.getSession({ path: { session_id: 'does-not-exist' } });
} catch (err) {
  if (err instanceof NotFoundError) {
    console.log('no such session');
  } else if (err instanceof APIError) {
    console.log(err.status, err.message, err.error); // err.error is the raw response body
  } else {
    throw err; // network/connection error (APIConnectionError, APIConnectionTimeoutError, ...)
  }
}

File uploads

Pass a File (built into Node 20+), or use toFile() for a Buffer/Blob/stream/async-iterable — it also works on Node 18, where File isn't a global:

import { Sessions, toFile } from 'anchorbrowser';

const session = await Sessions.createSession({
  body: { session: { recording: { active: true } } },
});

await Sessions.uploadFile({
  path: { sessionId: session.data.id },
  body: { file: await toFile(Buffer.from('data'), 'data.txt') },
});

Types

Request and response types are exported for every operation:

import type { CreateSessionData, SessionCreateResponseSchema, BrowserConfig } from 'anchorbrowser';

Requirements

TypeScript >= 4.9 and Node.js 18 LTS or later. The Playwright and agent helpers require Node.js.

Semantic versioning

This package generally follows SemVer conventions. The SDK surface is generated from the public OpenAPI spec; additions ship as minor versions, removals or renames as major versions.

We are keen for your feedback; please open an issue with questions, bugs, or suggestions.