Quickstart

In the next four steps you will install the SDK, grab an API key, rent your first browser, drive it through one navigation and one JavaScript evaluation, then release the session. Start to finish in under a minute.

TL;DR
  • Install the SDK in your language of choice.
  • Grab an API key from your dashboard.
  • Copy the example below and replace YOUR_API_KEY.
  • Run it; you should see Example Domain printed.

1. Install

go get github.com/browserscale/browserscale-go

Go users need Go 1.21+; Node users need Node 18+. The Go module ships the gRPC stubs precompiled, the npm package ships an ES-module build with bundled types.

2. Get an API key

A session is billed by use while it runs: its start, the time it is open, and the CPU and memory it uses, out of your account's balance. Nothing is taken upfront; the rent duration is only the longest the session may live. Top up your balance before you start.

  1. Sign up at browserscale.cloud/panel/register.
  2. Open the API keys in your account.
  3. Copy the sk_… value into the snippet below.

For development a plain .env file is fine; the SDK never reads env vars on its own, you always pass the key explicitly.

3. Your first script

The script below is the smallest end-to-end browserscale program. It rents a session, opens its first tab, navigates to example.com, waits for the page's h1 to appear, evaluates one line of JavaScript on the page, and stops cleanly. Every later example in these docs is just a variation on this skeleton — so it is worth reading the comments rather than just copy-pasting.

package main

import (
  "context"
  "fmt"
  "log"

  "github.com/browserscale/browserscale-go"
)

func main() {
  ctx := context.Background()

  // 1. Configure the rental. Empty proxy fields tell browserscale to allocate
  //    a managed proxy server-side; pass your own host/port/creds to
  //    bring your own.
  cfg := browserscale.NewBrowserConfig(
      "YOUR_API_KEY", // sk_…
      300,            // rentDuration in seconds (5 minutes)
      "", 0, "", "",  // proxy host / port / user / pass
  )

  // 2. Rent a fresh browser session.
  browser, err := browserscale.RentBrowser(ctx, cfg)
  if err != nil {
      log.Fatal(err)
  }
  defer browser.Close() // always release the session

  // 3. Open the first tab. A fresh session starts without one.
  page, err := browser.CreatePage(ctx)
  if err != nil {
      log.Fatal(err)
  }

  // 4. Drive it. Navigate returns when the page *commits*, so wait
  //    for an element you actually need before reading the DOM.
  if _, err := page.Navigate(ctx, "https://example.com", 0); err != nil {
      log.Fatal(err)
  }
  if _, err := page.Wait(ctx, browserscale.CSS("h1")); err != nil {
      log.Fatal(err)
  }

  res, err := page.Evaluate(ctx, "document.title")
  if err != nil {
      log.Fatal(err)
  }
  fmt.Println("title:", res.Value)
}

4. Run it

go run main.go
# title: Example Domain

If you see title: Example Domain, congratulations — the script just rented a real Chromium session somewhere on our infrastructure, opened a tab in it, drove that tab through a navigation and a JS call, and released the session. From here, every other method in the SDK is incremental.

See also
  • The Go SDK reference lists every method, signature, and option.
  • navigate returns when the page commits, not when it finishes loading — that distinction is covered in Core concepts.
  • evaluate is the escape hatch when no built-in method does what you need.