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/"
}Browser
Open browser
Open the browser in the specified box. If the browser is already open, repeated calls will not open a new browser.
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
Enter your API Key in the format: Bearer . Get it from https://gbox.ai
Body
application/json
Browser open configuration
Browser open config
Was this page helpful?