| title | BrowseFleet Python SDK |
|---|
Official Python SDK for BrowseFleet, the open-source browser API for AI agents.
One runtime dependency (httpx). Sync + async clients in one import. Full type hints with py.typed. Tested on Python 3.10, 3.11, 3.12, 3.13.
Working in this repo with an AI agent? Read
skill.mdfirst. It teaches Claude Code, Cursor, Aider, or any coding agent how to set up, run, test, and contribute to this repo with no further instruction.
The SDK is available from this repository. As of September 11, 2026, browsefleet is not published on PyPI; pip install browsefleet is not an available installation route.
Use Python 3.10 or newer. Create and activate a virtual environment, then install from the checkout:
git clone https://github.com/theRJMurray/browsefleet-python.git
cd browsefleet-python
python -m venv .venvActivate the environment on macOS/Linux:
source .venv/bin/activateOr activate it in Windows PowerShell:
.\.venv\Scripts\Activate.ps1Then install and check the import:
python -m pip install .
python -c "from browsefleet import BrowseFleet, AsyncBrowseFleet; print('BrowseFleet import OK')"The SDK needs a running BrowseFleet server. Follow the server repo's Quick start to spin one up via Docker or local Node dev.
from browsefleet import BrowseFleet
bf = BrowseFleet(
base_url="http://localhost:3000", # or BROWSEFLEET_URL env var
api_key="optional-when-server-requires-it", # or BROWSEFLEET_API_KEY env var
)
# Scrape a page
page = bf.scrape("https://example.com")
print(page.title, page.markdown[:200])
# Take a screenshot
png = bf.screenshot("https://example.com", full_page=True)
with open("example.png", "wb") as f:
f.write(png)
# Generate a PDF
pdf = bf.pdf("https://example.com", format="A4", print_background=True)
# Spin up a persistent session
session = bf.sessions.create(stealth="full")
bf.sessions.actions(session.id, [
{"type": "navigate", "url": "https://example.com"},
{"type": "screenshot"},
])
bf.sessions.release(session.id)
# Vision-based agent task
result = bf.agent.run(
task="Extract the most expensive product price from this page",
url="https://example.com/products",
provider="anthropic",
max_iterations=10,
)
print(result.success, result.result)import asyncio
from browsefleet import AsyncBrowseFleet
async def main():
async with AsyncBrowseFleet(base_url="http://localhost:3000") as bf:
page = await bf.scrape("https://example.com")
print(page.title)
asyncio.run(main())Both clients share the same public surface. Same methods, same return types, same typed errors.
- Sessions, scrape, screenshot, PDF, agent, profiles, files, CAPTCHA. Full coverage of the BrowseFleet REST surface.
- Operator mode. Sessions can start in
humancontrol, hand off toagentviasessions.control(). - Typed errors.
AuthError,NotFoundError,RateLimitError,ValidationError,ServerError, all extendingBrowseFleetError. - Auto-retry. Exponential backoff on
429/5xx, honorsRetry-After. Configurable per client viamax_retries. - Env-var fallback.
BROWSEFLEET_URLandBROWSEFLEET_API_KEYare read when not passed explicitly. - Sync + async.
BrowseFleetandAsyncBrowseFleet. Both implement context-manager protocol. - Typed.
py.typedmarker, dataclass return types,TypedDictrequest params. Mypy checks function annotations and bodies across the source; strict mode is not enabled.
BrowseFleet(
base_url="http://localhost:3000", # or BROWSEFLEET_URL env (default: http://localhost:3000)
api_key="optional", # or BROWSEFLEET_API_KEY env (omit if server is authless)
timeout=60.0, # seconds, default 60
max_retries=2, # retries on 429 / 5xx, default 2
)See examples/ for runnable mini-projects:
examples/quickstart/, scrape + screenshot + releaseexamples/agent_task/, vision-based agent taskexamples/operator_mode/, human-to-agent handoff via profile + control state machineexamples/async_client/, the same flows onAsyncBrowseFleet
PRs welcome. Read CONTRIBUTING.md and skill.md. Conventional Commits, squash-merge, base branch is master.
Do not file security issues publicly. See SECURITY.md.
MIT. See LICENSE.