Skip to main content
Requires Node.js 22 or newer, or Bun. The surfsky package uses ES modules and includes TypeScript definitions.
Set SURFSKY_API_TOKEN and SURFSKY_API_BASE_URL from the dashboard. See credential setup. You can also pass apiToken and baseUrl to the constructor.

Start a browser

Save as first-browser.mjs and run node first-browser.mjs. The same code can be used in a TypeScript project configured for ESM.
Expected output is Example Domain. browser.close() stops the session. Put it in finally so it also runs when a page operation throws. Cleanup cannot complete if the process is forcibly terminated or loses access to the API. On runtimes that support explicit resource management, such as Node.js 24+ or Bun, await using can handle cleanup at scope exit:
For Node.js 22, use try/finally or a TypeScript build that transforms await using for your runtime.

Interact with the page

Methods include goto, click, type, hover, innerText, and waitForSelector. Run page operations while the browser is open, using selectors from your target page:
evaluate() runs JavaScript in an isolated execution context by default. Use isolated: false to access variables defined by the page. DOM changes remain visible to the page.

Save traffic

Choose resource types when starting a browser:
Close this browser after use. Keep resources required by your target page; see Speed optimization.

Capture a page’s API response

Start capture before navigation. Adapt the URL and response path to your application:

Multiple tabs

browser operates on the first tab. browser.pages contains other tabs and popups:
See the session page limit.

Running many browsers

The pool collects an outcome for each job and can reuse browsers between jobs. Leases retain browser state, including cookies. Do not assume each item receives an empty browser. For manual leasing on Node.js 24+ or Bun:
See Concurrency for account limits and work distributed across processes.

Proxies

Pass proxy to browser() or session():
You can also select tier: "shared" or supply a proxy URL. Close the browser after use. client.proxies provides location and quota lookups; see Proxies.

Profiles

Save profile.uuid and start that profile on later runs. See Sessions for login persistence.

Raw requests

request() returns the raw response and does not throw on HTTP status. The SDK repository contains the complete method reference and examples.