import GboxSDK from "gbox-sdk";
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" });
// Open a new tab with Google
const newTab = await box.browser.openTab({
url: "https://www.google.com"
});
console.log(`New tab opened successfully:`);
console.log(` Id: ${newTab.id}`);
console.log(` Title: ${newTab.title}`);
console.log(` URL: ${newTab.url}`);
// Open multiple tabs
const urls = ["https://github.com", "https://stackoverflow.com", "https://developer.mozilla.org"];
for (const url of urls) {
const tab = await box.browser.openTab({ url });
console.log(`Opened tab: ${tab.title} - ${tab.url}`);
}
}
main();import os
from gbox_sdk import GboxSDK
def main():
gbox_sdk = GboxSDK(api_key=os.environ["GBOX_API_KEY"])
box = gbox_sdk.create(type="linux")
# Open a new tab with Google
new_tab = box.browser.open_tab(
url="https://www.google.com"
)
print(f"New tab opened successfully:")
print(f" Id: {new_tab.id}")
print(f" Title: {new_tab.title}")
print(f" URL: {new_tab.url}")
# Open multiple tabs
urls = [
"https://github.com",
"https://stackoverflow.com",
"https://developer.mozilla.org"
]
for url in urls:
tab = box.browser.open_tab(url=url)
print(f"Opened tab: {tab.title} - {tab.url}")
if __name__ == "__main__":
main()curl --request POST \
--url https://gbox.ai/api/v1/boxes/{boxId}/browser/tabs \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "https://www.google.com"
}
'{
"id": "1",
"title": "Google",
"url": "https://www.google.com",
"favicon": "https://www.google.com/favicon.ico",
"active": true,
"loading": false
}Open a new browser tab
Create and open a new browser tab with the specified URL. This endpoint will navigate to the provided URL and return the new tab’s information including its assigned id, loaded title, final URL (after any redirects), and favicon. The returned tab id can be used for future operations on this specific tab. The browser will attempt to load the page and will wait for the DOM content to be loaded before returning the response. If the URL is invalid or unreachable, an error will be returned.
import GboxSDK from "gbox-sdk";
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" });
// Open a new tab with Google
const newTab = await box.browser.openTab({
url: "https://www.google.com"
});
console.log(`New tab opened successfully:`);
console.log(` Id: ${newTab.id}`);
console.log(` Title: ${newTab.title}`);
console.log(` URL: ${newTab.url}`);
// Open multiple tabs
const urls = ["https://github.com", "https://stackoverflow.com", "https://developer.mozilla.org"];
for (const url of urls) {
const tab = await box.browser.openTab({ url });
console.log(`Opened tab: ${tab.title} - ${tab.url}`);
}
}
main();import os
from gbox_sdk import GboxSDK
def main():
gbox_sdk = GboxSDK(api_key=os.environ["GBOX_API_KEY"])
box = gbox_sdk.create(type="linux")
# Open a new tab with Google
new_tab = box.browser.open_tab(
url="https://www.google.com"
)
print(f"New tab opened successfully:")
print(f" Id: {new_tab.id}")
print(f" Title: {new_tab.title}")
print(f" URL: {new_tab.url}")
# Open multiple tabs
urls = [
"https://github.com",
"https://stackoverflow.com",
"https://developer.mozilla.org"
]
for url in urls:
tab = box.browser.open_tab(url=url)
print(f"Opened tab: {tab.title} - {tab.url}")
if __name__ == "__main__":
main()curl --request POST \
--url https://gbox.ai/api/v1/boxes/{boxId}/browser/tabs \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"url": "https://www.google.com"
}
'{
"id": "1",
"title": "Google",
"url": "https://www.google.com",
"favicon": "https://www.google.com/favicon.ico",
"active": true,
"loading": false
}Authorizations
Enter your API Key in the format: Bearer . Get it from https://gbox.ai
Path Parameters
Box ID
"c9bdc193-b54b-4ddb-a035-5ac0c598d32d"
Body
URL to open in the new tab
Open tab
The tab url
"https://www.google.com"
Response
Successfully opened new tab
Browser tab
The tab id
"1"
The tab title
"Google"
The tab url
"https://www.google.com"
The tab favicon
"https://www.google.com/favicon.ico"
Whether the tab is the current active (frontmost) tab
true
Whether the tab is currently in a loading state.
The value is true while the browser is still navigating to the target URL or fetching sub-resources (i.e. document.readyState is not "complete"). It typically switches to false once the load event fires and all major network activity has settled.
false
Was this page helpful?