POST
/
boxes
/
{boxId}
/
browser
/
open
JavaScript
import GboxSDK from "gbox-sdk";
import { chromium } from "playwright";

const gboxSDK = new GboxSDK({
  apiKey: process.env["GBOX_API_KEY"] // This is the default and can be omitted
});

async function main() {
  const box = await gboxSDK.create({ type: "linux" });

  const result = await box.browser.open({
    maximize: true,
    showControls: false,
  })

  const browser = await chromium.connectOverCDP(result.cdpUrl);

  // Use the browser as usual
  const context = await browser.newContext();
  const page = await context.newPage();
  await page.goto("https://example.com");

  // Perform actions on the page
  console.log(await page.title());

  await box.browser.close()
}

main();
{
  "cdpUrl": "https://gbox.ai/api/v1/boxes/031df7cd-baa4-4d50-92ee-4ceaf04b0905/browser/connect/"
}

Authorizations

Authorization
string
header
required

Enter your API Key in the format: Bearer <token>. Get it from https://gbox.ai

Path Parameters

boxId
string
required

Box ID

Example:

"c9bdc193-b54b-4ddb-a035-5ac0c598d32d"

Body

application/json

Browser open configuration

Browser open config

showControls
boolean
default:true

Whether to show the browser's minimize, maximize and close buttons. Default is true.

Example:

true

maximize
boolean

Whether to maximize the browser window.

Example:

false

size
string

The window size, format: <width>x<height>. If not specified, the browser will open with the default size. If both maximize and size are specified, maximize will take precedence.

Example:

"1024x768"

Response

200 - application/json

Successfully opened the browser, return the CDP url

Browser open result

cdpUrl
string
required

The CDP url. You can use this URL with CDP libraries like puppeteer/playwright/etc.

Example:

"https://gbox.ai/api/v1/boxes/031df7cd-baa4-4d50-92ee-4ceaf04b0905/browser/connect/"