Setup your Environment
To use Hyperbrowser with your code, you will need an API Key. You can get one easily from the . Once you have your API Key, add it to your .env
file as HYPERBROWSER_API_KEY
.
Crawl a Site
Next, you can crawl any site by simply setting up the Hyperbrowser client and providing the site's url.
Node Python
Copy import { Hyperbrowser } from "@hyperbrowser/sdk";
import { config } from "dotenv";
config();
const client = new Hyperbrowser({
apiKey: process.env.HYPERBROWSER_API_KEY,
});
const main = async () => {
const crawlResult = await client.crawl.startAndWait({
url: "https://hyperbrowser.ai",
maxPages: 5,
});
console.log("Crawl result:", crawlResult);
};
main();
Copy import asyncio
import os
from dotenv import load_dotenv
from hyperbrowser import AsyncHyperbrowser as Hyperbrowser
from hyperbrowser.models import StartCrawlJobParams
# Load environment variables from .env file
load_dotenv()
# Initialize Hyperbrowser client
client = Hyperbrowser(api_key=os.getenv("HYPERBROWSER_API_KEY"))
async def main():
# Start crawling and wait for completion
crawl_result = await client.crawl.start_and_wait(
StartCrawlJobParams(url="https://hyperbrowser.ai", max_pages=5)
)
print("Crawl result:")
print(crawl_result.model_dump_json(indent=2))
if __name__ == "__main__":
asyncio.run(main())
View Session in Dashboard
You can view all your sessions in the and see their recordings or other key metrics like logs.