Python SDK
Learn about Hyperbrowser Python SDK
Installation
Usage
Create Session
Creates a new browser session.
Method:
client.create_session(): SessionDetail
Endpoint:
POST /api/session
Parameters:
CreateSessionParams
:use_stealth?: bool
- Use stealth mode.use_proxy?: bool
- Use proxy.proxy_server?: string
- Proxy server URL to route the session through.proxy_server_username?: string
- Username for proxy server authentication.proxy_server_password?: string
- Password for proxy server authentication.proxy_country?: Country
- Desired proxy country.operating_systems?: OperatingSystem[]
- Preferred operating systems for the session. Possible values are:OperatingSystem.WINDOWS
OperatingSystem.ANDROID
OperatingSystem.MACOS
OperatingSystem.LINUX
OperatingSystem.IOS
device?: ("desktop" | "mobile")[]
- Preferred device types. Possible values are:"desktop"
"mobile"
platform?: Platform[]
- Preferred browser platforms. Possible values are:Platform.CHROME
Platform.FIREFOX
Platform.SAFARI
Platform.EDGE
locales?: ISO639_1[]
- Preferred locales (languages) for the session. Use ISO 639-1 codes.screen?: ScreenConfig
- Screen configuration for the session.width: number
- Screen width.height: number
- Screen height.
solve_captchas: bool
- Solve captchas.adblock: bool
- Block ads.trackers: bool
- Block trackers.annoyances: bool
- Block annoyances.
Response:
SessionDetail
Example:
Get Session Details
Retrieves details of a specific session.
Method:
client.get_session(id: str): SessionDetail
Endpoint:
GET /api/session/{id}
Parameters:
id: str
- Session ID
Response:
SessionDetail
Example:
List Sessions
Retrieves a list of all sessions with optional filtering.
Method:
client.get_session_list(params: SessionListParams): SessionListResponse
Endpoint:
GET /api/sessions
Parameters:
SessionListParams
:status?: "active" | "closed" | "error"
- Filter sessions by statuspage?: int
- Page number (default: 1, min: 1)per_page?: int
- Results per page (default: 20, min: 1, max: 100)
Response:
SessionListResponse
Example:
Stop Session
Stops a running session.
Method:
client.stop_session(id: str): BasicResponse
Endpoint:
PUT /api/session/{id}/stop
Parameters:
id: str
- Session ID
Response:
BasicResponse
Example:
Start Scrape Job
Starts a scrape job for a given URL.
Method:
client.start_scrape_job(params: StartScrapeJobParams): StartScrapeJobResponse
Endpoint:
POST /api/scrape
Parameters:
StartScrapeJobParams
:url: str
- URL to scrapeuse_proxy: bool
- Use proxysolve_captchas: bool
- Solve captchas
Response:
StartScrapeJobResponse
Example:
Get Scrape Job
Retrieves details of a specific scrape job.
Method:
client.get_scrape_job(id: str): ScrapeJobResponse
Endpoint:
GET /api/scrape/{id}
Parameters:
id: str
- Scrape job ID
Response:
ScrapeJobResponse
Example:
Start Crawl Job
Starts a crawl job for a given URL.
Method:
client.start_crawl_job(params: StartCrawlJobParams): StartCrawlJobResponse
Endpoint:
POST /api/crawl
Parameters:
StartCrawlJobParams
:url: str
- URL to crawlmax_pages: int
- Maximum number of pages to crawlfollow_links: bool
- Follow linksexclude_patterns: List[str]
- Patterns to exclude from the crawlinclude_patterns: List[str]
- Patterns to include in the crawluse_proxy: bool
- Use proxysolve_captchas: bool
- Solve captchas
Response:
StartCrawlJobResponse
Example:
Get Crawl Job
Retrieves details of a specific crawl job.
Method:
client.get_crawl_job(id: str): CrawlJobResponse
Endpoint:
GET /api/crawl/{id}
Parameters:
id: str
- Crawl job ID
Response:
CrawlJobResponse
Example:
Types
BasicResponse
Session
SessionDetail
SessionListParams
SessionListResponse
CreateSessionParams
ScreenConfig
StartScrapeJobParams
StartScrapeJobResponse
ScrapeJobMetadata
ScrapeJobData
ScrapeJobResponse
StartCrawlJobParams
StartCrawlJobResponse
CrawledPageMetadata
CrawledPage
GetCrawlJobParams
CrawlJobResponse
SessionStatus
Country
OperatingSystem
Platform
ISO639_1
ScrapeJobStatus
CrawlJobStatus
Client Initialization
Example: