POST
/
boxes
/
{boxId}
/
browser
/
connect-url
/
cdp
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" });

  // Get browser CDP URL for Chrome DevTools Protocol connection
  const cdpUrl = await box.browser.cdpUrl();

  console.log(`Browser CDP URL: ${cdpUrl}`);

  const browser = await chromium.connectOverCDP(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());

  // Close the browser
  await browser.close();
}

main();
"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

Generate pre-signed CDP url

Generate cdp url

Response

200 - application/json

Generate pre-signed CDP url

The response is of type string.

Example:

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