Skip to main content
The AdsCrawl JavaScript SDK works in Node.js 20 and later, supports both ESM and CommonJS, and ships with full TypeScript types and editor autocomplete. It uses native fetch and has zero runtime dependencies.
Keep your API key in server-side code. The SDK is not designed for use in browser bundles.

Install

When you need to connect a remote browser with Playwright or Puppeteer, install the automation library separately:

adscrawl-js on GitHub

View source, runnable examples, and releases.

Authenticate and make your first request

Create an API key in the dashboard and set ADSCRAWL_API_KEY in your server environment. You can also pass the key explicitly to new AdsCrawl({ apiKey: '...' }).
CommonJS:

Rendered content and screenshots

html() returns a string for contentMode: 'html' (the default) or 'markdown', and an Article for 'json'. markdown() and article() are conveniences for those modes. screenshot() returns a Uint8Array containing a PNG.

Proxy and fingerprint

Route through a custom proxy or use managed countryCode routing. Both cannot be combined.
AdsCrawl uses real browsers with configurable routing and browser fingerprints. Randomized settings are generated as a coherent profile across the operating system, GPU, hardware, fonts, and related signals. This browser workflow has been verified to access and render BrowserScan, Pixelscan, and IPhey and return screenshots. This complete example opens BrowserScan and saves the returned PNG as browserscan.png:

Structured extraction

List available templates and their parameters:
For your own page, specify DOM or network fields. A generic describes the expected output but does not validate your custom data at runtime. Always check missingFields.
Use actions for clicks, input, scrolling, and waits, and waitFor for a visible selector or text. See the API reference for template-specific requirements.

Remote CDP browsers

Connect a Playwright browser over CDP to an AdsCrawl remote session:
The creation response contains sessionId, expiresAt, and cdpBaseUrl. It does not contain a WebSocket URL. For Puppeteer, use discovery:
cdp.list() returns { ok, data }. cdp.liveToken(sessionId) returns a single-use live-control URL valid for 30 seconds. Treat all connection URLs as secrets and do not log them.

Persistent cloud browsers

Cloud browser profiles retain their configuration after stop. API-key starts require an explicit, top-level custom proxy on every start, even when a proxy was saved in the profile. Set ADSCRAWL_PROXY_SERVER to your HTTP or SOCKS5 proxy URL with an explicit port. If authentication is needed, also set ADSCRAWL_PROXY_USERNAME and ADSCRAWL_PROXY_PASSWORD.
cloudBrowsers.launch({ proxy, tabs?, cookies?, fingerprint? }) creates a persistent profile and starts it in one request. Failed launches can return a profile id in AdsCrawlAPIError.id; inspect and stop that profile. If no id was received, inspect cloudBrowsers.list() before repeating the launch. cloudBrowsers.list({ page?, pageSize? }) includes pagination and saved/running quotas. A stop response with runtime.status: 'stopping' means shutdown is pending and quota is still reserved. Closing the viewer does not stop billing. The SDK covers API-key endpoints; profile configuration PATCH/DELETE and viewer authentication require a dashboard session.

Configuration, deadlines, and cancellation

The API key defaults to ADSCRAWL_API_KEY. The API origin defaults to ADSCRAWL_BASE_URL, then ADSCRAWL_API_URL, then https://api.adscrawl.net. HTTP deadlines cover both the request and reading its response. Ordinary calls default to 90 seconds; cloudBrowsers.launch() defaults to 195 seconds to allow startup and server cleanup. For long tasks, set an HTTP deadline greater than the server task timeout.
Cancellation or a deadline does not prove remote work stopped.

Errors

API errors preserve HTTP status, stable code, redacted body, traceId, and requestId when available. Network failures use AdsCrawlConnectionError; invalid or empty responses use AdsCrawlResponseError. Caller cancellation preserves the AbortSignal reason. Requests are never automatically retried.