Extensions
Using Extensions with Hyperbrowser
Hyperbrowser allows you to enhance your browser sessions with custom Chrome extensions.
Uploading an Extension
To use a custom extension with Hyperbrowser:
Create your extension as a directory containing at least a manifest.json
file
Compress the directory into a ZIP archive, make sure to zip all the files and not the directory itself
Upload the ZIP file using the Extensions API:
import { Hyperbrowser } from "@hyperbrowser/sdk";
import { config } from "dotenv";
config();
const hbClient = new Hyperbrowser({ apiKey: process.env.HYPERBROWSER_API_KEY });
const uploadExtension = async () => {
const resp = await hbClient.extensions.create({
name: "new-extension",
filePath: "custom-extension.zip",
});
console.log(resp);
};
uploadExtension();
import asyncio
import os
from hyperbrowser import AsyncHyperbrowser
from hyperbrowser.models.extension import CreateExtensionParams
from dotenv import load_dotenv
load_dotenv()
hb_client = AsyncHyperbrowser(api_key=os.getenv("HYPERBROWSER_API_KEY"))
async def upload_extension():
res = await hb_client.extensions.create(
CreateExtensionParams(name="new-extension", file_path="custom-extension.zip")
)
print(res)
if __name__ == "__main__":
asyncio.run(upload_extension())
The API will return an id
that you'll use to attach the extension to a session.
Using an Extension
To use your uploaded extension in a Hyperbrowser session, simply add it in the extensionIds
field of the Create Session params:
import { Hyperbrowser } from "@hyperbrowser/sdk";
import { config } from "dotenv";
config();
const hbClient = new Hyperbrowser({ apiKey: process.env.HYPERBROWSER_API_KEY });
const useExtensionInSession = async () => {
const resp = await hbClient.sessions.create({
extensionIds: ["<EXTENSION_ID>"],
});
console.log(resp);
};
useExtensionInSession();
import asyncio
import os
from hyperbrowser import AsyncHyperbrowser
from hyperbrowser.models.session import CreateSessionParams
from dotenv import load_dotenv
load_dotenv()
hb_client = AsyncHyperbrowser(api_key=os.getenv("HYPERBROWSER_API_KEY"))
async def use_extension_in_session():
res = await hb_client.sessions.create(
CreateSessionParams(extension_ids=["<EXTENSION_ID>"])
)
print(res)
if __name__ == "__main__":
asyncio.run(use_extensionin_session())
Once added to a session, these extension behave exactly as they would in a real browser.
Refer to the Extensions API Reference for more details on uploading and managing extensions.