Skip to content
Ant0 Docs
Create free account

SDKs

Availability

Node and Python SDKs 0.2.0 are publicly available. Install them separately from the desktop app:

Node.js

Terminal window
npm install ant0-browser@0.2.0

Node package and quickstart

Python

Terminal window
python -m pip install ant0-browser==0.2.0

Python package and quickstart

Neither SDK is bundled in desktop installers or portable CLI/MCP archives.

For direct SDK launches, install a matching Ant0 Browser engine and set ANT0_BROWSER_BINARY to its executable. Keep a signed-in, licensed local ant0d daemon available for launch-ticket requests. Package metadata declares Node.js 18+ and Python 3.9+; these are declared runtime minimums, not a claim that those lowest versions were tested. For automation without the SDK packages, use the local API examples below. See Command line for separate CLI/MCP availability.

Two ways to automate

Most scripts need no SDK: start an existing profile through the local API and connect Playwright or another CDP client to the returned endpoint. The profile's identity, proxy, cookies and extensions are already applied by the background service. Install the client library, not a browser: these examples attach to the engine already started by Ant0.

Set ANT0_TOKEN from Desktop → Automation without printing it or putting it in a command argument. Set ANT0_PROFILE_ID to an existing, stopped test profile ID; set ANT0D_PORT only if the local service uses a different port (default 27100). Use a dedicated profile and one runner at a time because cleanup stops the profile's running browser generation.

These examples call POST /v1/profiles/{id}/start, which returns the full Session including ws_endpoint. Do not substitute /run: that route intentionally does not return a CDP endpoint. A delegated API key needs both profiles:run and profiles:cdp for /start, plus profiles:stop for cleanup. The Desktop Automation token is not least-privilege scoped; keep it private. If start fails or its response is ambiguous, inspect profile state in Ant0 before taking action: the examples do not retry or stop a session they cannot confirm.

Node, without the Ant0 SDK

Terminal window
npm install playwright
import { chromium } from "playwright";
const token = process.env.ANT0_TOKEN;
const profileId = process.env.ANT0_PROFILE_ID;
const port = process.env.ANT0D_PORT || "27100";
if (!token || !profileId) throw new Error("Set ANT0_TOKEN and ANT0_PROFILE_ID in the environment");
const profile = encodeURIComponent(profileId);
const base = "http://127.0.0.1:" + port;
async function post(path) {
const response = await fetch(base + path, {
method: "POST",
headers: { authorization: "Bearer " + token, "content-type": "application/json" },
body: "{}",
});
if (!response.ok) throw new Error("Ant0 API failed: HTTP " + response.status);
return response.status === 204 ? null : response.json();
}
let started = false;
let failure;
try {
const session = await post("/v1/profiles/" + profile + "/start");
if (!session?.ws_endpoint) throw new Error("Start returned no usable Session.ws_endpoint");
started = true;
const browser = await chromium.connectOverCDP(session.ws_endpoint);
const page = await browser.contexts()[0].newPage();
await page.goto("https://example.com");
console.log(await page.title());
} catch (error) {
failure = error;
if (!started) failure = new Error("Start may be ambiguous. Do not retry or stop an unknown session; inspect profile state in Ant0.", { cause: error });
} finally {
if (started) {
try {
await post("/v1/profiles/" + profile + "/stop");
} catch (stopError) {
failure = failure ? new AggregateError([failure, stopError], "Automation and profile stop both failed") : stopError;
}
}
}
if (failure) throw failure;

Save as automate.mjs and run node automate.mjs with Node.js 18+; the example uses built-in fetch.

Python, without the Ant0 SDK

Python uses its standard library for the HTTP calls; Playwright is the only extra dependency.

Terminal window
python -m pip install playwright
import json
import os
from urllib.error import HTTPError
from urllib.parse import quote
from urllib.request import Request, urlopen
from playwright.sync_api import sync_playwright
token = os.environ.get("ANT0_TOKEN")
profile_id = os.environ.get("ANT0_PROFILE_ID")
base = "http://127.0.0.1:" + os.environ.get("ANT0D_PORT", "27100")
if not token or not profile_id:
raise RuntimeError("Set ANT0_TOKEN and ANT0_PROFILE_ID in the environment")
profile = quote(profile_id, safe="")
headers = {"Authorization": "Bearer " + token, "Content-Type": "application/json"}
def post(path):
request = Request(base + path, data=b"{}", headers=headers, method="POST")
try:
with urlopen(request) as response:
return None if response.status == 204 else json.loads(response.read())
except HTTPError as error:
raise RuntimeError("Ant0 API failed: HTTP " + str(error.code)) from error
started = False
failure = None
try:
session = post("/v1/profiles/" + profile + "/start")
endpoint = session.get("ws_endpoint") if isinstance(session, dict) else None
if not endpoint:
raise RuntimeError("Start returned no usable Session.ws_endpoint")
started = True
with sync_playwright() as playwright:
browser = playwright.chromium.connect_over_cdp(endpoint)
page = browser.contexts[0].new_page()
page.goto("https://example.com")
print(page.title())
except Exception as error:
failure = error
if not started:
failure = RuntimeError("Start may be ambiguous. Do not retry or stop an unknown session; inspect profile state in Ant0. " + str(error))
failure.__cause__ = error
finally:
if started:
try:
post("/v1/profiles/" + profile + "/stop")
except Exception as stop_error:
if failure is not None:
raise stop_error from failure
raise
if failure is not None:
raise failure

Save as automate.py and run python automate.py.

Each sample calls the API /stop route in finally only after a successful start response supplied a usable Session. That route controls the Ant0 profile lifecycle. The examples do not call browser.close() over CDP or assume it only disconnects the client. A failed start is never retried or followed by a stop for an unconfirmed session, and a stop failure is raised rather than hidden.

The SDKs cover another case: launching Ant0 Browser directly from your own code, with an identity you choose. They wrap Playwright's launcher and add the identity layer, launch-ticket handling, geo resolution and helpers. The samples use native identity, which needs no synthetic template assets. A new synthetic identity requires authorized local model or template assets; the packages include neither and do not bypass engine licensing.

Node SDK

import { launch } from "ant0-browser";
const browser = await launch({
identity: { mode: "native" },
});
try {
const page = await browser.newPage();
await page.goto("https://example.com");
} finally {
await browser.close();
}

Set ANT0_BROWSER_BINARY instead of passing executablePath on every call. Current source entry points:

  • launch() and launchPersistentContext(): Playwright browsers with the identity applied.
  • serve(): a raw CDP endpoint (cdpUrl, pid, isAlive(), close()) for other clients.
  • launchPlan(): for supervisors that spawn the browser themselves; returns the executable, arguments, environment and user-data directory.
  • Native, captured and persisted synthetic identities; fingerprint-profile encoding, geometry and coherence warnings.
  • Humanised input wrappers and rendering checks; optional geo (resolveGeo()) and Widevine helpers.

Python SDK

from ant0browser import launch
browser = launch(
identity={"mode": "native"},
)
try:
page = browser.new_page()
page.goto("https://example.com")
finally:
browser.close()

The async API mirrors launch and persistent contexts:

import asyncio
from ant0browser.async_api import launch
async def main():
browser = await launch(identity={"mode": "native"})
try:
page = await browser.new_page()
await page.goto("https://example.com")
finally:
await browser.close()
if __name__ == "__main__":
asyncio.run(main())

serve() and the ant0-browser-serve command give a local CDP endpoint; the helper set matches the Node SDK (identities, templates, humanised input, rendering checks, geo, Widevine).

Identity options

Omitting identity means native mode: the browser presents the machine it runs on. { mode: "synthetic", key } derives a coherent identity from the key, so the same key gives the same identity on every run. Explicit switches go under overrides: platform, platformVersion, brand, brandVersion, gpuVendor, gpuRenderer, hardware and display fields, location, timezone, acceptLanguage, WebRTC, GPU and noise controls, storageQuota and tlsProfile (snake_case in Python). Overrides take precedence over captured or synthetic profiles.

Network calls

launch and serve can make a loopback request to the local background service for the engine's launch ticket; the service's account connections are listed in What leaves your computer. Optional SDK helpers connect only when called:

HelperEndpointPurpose
resolveGeo()ip.ant0.link; last-resort fallbacks api.ipify.org and ip-api.com, through the configured proxyExit-IP and country lookup. The primary service keeps no request logs; third-party fallbacks have their own policies.
resolveGeo()releases.ant0.linkGeoIP database (about 52 MB), fetched directly when a proxy check finds the 30-day local cache missing or stale.
release installANT0_BROWSER_RELEASE_URL (opt-in)Signed engine releases, verified against the key embedded in the SDK.

Geo data attribution: this product uses the IP2Location LITE database (lite.ip2location.com); includes GeoLite2 data created by MaxMind (maxmind.com); IP geolocation by DB-IP (db-ip.com).

Known engine behaviours

  • SOCKS5 with a username and password is not supported by the engine (Chromium has no such client). The SDKs refuse it; use an HTTP proxy with credentials, a SOCKS5 proxy that allows your IP, or the background service's relay by starting the profile through Ant0.
  • Launch tickets. The engine refuses to start without a ticket issued by a signed-in background service; the SDKs fetch one automatically when the service is reachable. Without one the engine exits with code 90.