Skip to main content
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();
import os
import asyncio
from gbox_sdk import GboxSDK
from playwright.async_api import async_playwright

async def main():
gbox_sdk = GboxSDK(api_key=os.environ["GBOX_API_KEY"])

box = gbox_sdk.create(type="linux")

# Open browser with configuration
result = await box.browser.open(
maximize=True,
showControls=False
)

async with async_playwright() as p:
browser = await p.chromium.connect_over_cdp(result.cdp_url)

# Use the browser as usual
context = await browser.new_context()
page = await context.new_page()
await page.goto("https://example.com")

# Perform actions on the page
title = await page.title()
print(title)

# Close the browser
await browser.close()

await box.browser.close()

if __name__ == "__main__":
asyncio.run(main())
curl --request POST \
--url https://gbox.ai/api/v1/boxes/{boxId}/browser/open \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"showControls": true,
"maximize": false,
"size": "1024x768"
}
'
{
  "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 . 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: x. 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/"