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.
- 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 Domainprinted.
1. Install
go get github.com/browserscale/browserscale-gonpm install browserscale-tsGo 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.
- Sign up at browserscale.cloud/panel/register.
- Open the API keys in your account.
- 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)
}import { rentBrowser, BrowserConfig, css } from "browserscale-ts";
async function main() {
// 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.
const cfg = new BrowserConfig(
"YOUR_API_KEY", // sk_…
300, // rentDuration in seconds (5 minutes)
"", 0, "", "", // proxy host / port / user / pass
);
// 2. Rent a fresh browser session.
const browser = await rentBrowser(cfg);
try {
// 3. Open the first tab. A fresh session starts without one.
const page = await browser.createPage();
// 4. Drive it. navigate returns when the page *commits*, so
// wait for an element you actually need before reading the DOM.
await page.navigate("https://example.com");
await page.wait(css("h1"));
const res = await page.evaluate("document.title");
console.log("title:", res.value);
} finally {
await browser.stopBrowser(); // always release the session
}
}
main();4. Run it
go run main.go
# title: Example Domain# save as quickstart.ts
npx tsx quickstart.ts
# title: Example DomainIf 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.
- The Go SDK reference lists every method, signature, and option.
navigatereturns when the page commits, not when it finishes loading — that distinction is covered in Core concepts.evaluateis the escape hatch when no built-in method does what you need.