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 .
3
Extract Data
Next, you can extract data from any site by simply setting up the Hyperbrowser client and providing any site urls and the schema you want the data in.
import { Hyperbrowser } from "@hyperbrowser/sdk";
import { config } from "dotenv";
import { z } from "zod";
config();
const client = new Hyperbrowser({
apiKey: process.env.HYPERBROWSER_API_KEY,
});
const main = async () => {
const schema = z.object({
productName: z.string(),
productOverview: z.string(),
keyFeatures: z.array(z.string()),
pricing: z.array(
z.object({
plan: z.string(),
price: z.string(),
features: z.array(z.string()),
})
),
});
// Handles both starting and waiting for extract job response
const result = await client.extract.startAndWait({
urls: ["https://hyperbrowser.ai"],
prompt:
"Extract the product name, an overview of the product, its key features, and a list of its pricing plans from the page.",
schema: schema,
});
console.log("result", JSON.stringify(result, null, 2));
};
main();
import os
import json
from typing import List
from dotenv import load_dotenv
from hyperbrowser import Hyperbrowser
from hyperbrowser.models import StartExtractJobParams
from pydantic import BaseModel
# Load environment variables from .env file
load_dotenv()
# Initialize Hyperbrowser client
client = Hyperbrowser(api_key=os.getenv("HYPERBROWSER_API_KEY"))
class PricingSchema(BaseModel):
plan: str
price: str
features: List[str]
class ExtractSchema(BaseModel):
product_name: str
product_overview: str
key_features: List[str]
pricing: List[PricingSchema]
def main():
result = client.extract.start_and_wait(
params=StartExtractJobParams(
urls=["https://hyperbrowser.ai"],
prompt="Extract the product name, an overview of the product, its key features, and a list of its pricing plans from the page.",
schema=ExtractSchema,
)
)
print("result:", json.dumps(result.data, indent=2))
main()
4
View Session in Dashboard
You can view all your sessions in the and see their recordings or other key metrics like logs.