Manage browser profiles across cloud storage providers
Project description
🧠 BrowserState for Python
Auth & memory for AI agents and browser automation — now in Python.
BrowserState lets agents and automation tools act like real, returning users. It captures and restores full browser session state — enabling persistent identity, stable automation, and reliable behavior at scale.
🚀 Install
pip install browserstate
Or with uv:
uv pip install browserstate
🧭 Why BrowserState?
Most browser automations fail because sessions reset every run. Fingerprints drift, cookies vanish, and re-auth prompts kill workflows.
BrowserState makes browser identity portable.
It captures and restores the full browser context: cookies, storage, fingerprints, service workers, and more — across environments and tools.
✨ Key Features
- ✅ Full browser context save & restore
- 🔁 Portable across machines, clouds, CI pipelines
- 🧠 Works with Playwright, Selenium, Pyppeteer, AI agents
- 🛡️ Bot detection resistant (no more fingerprint drift)
- ☁️ Pluggable storage (Local, Redis, S3, GCS)
- 🐛 Capture failed sessions for debugging + rehydration
🛠️ Quickstart
1. Configure BrowserState
from browserstate import BrowserState, BrowserStateOptions
options = BrowserStateOptions(
user_id="user-123",
local_storage_path="./sessions"
)
state = BrowserState(options)
🔐 Example: Automating Login + Capturing State (LinkedIn)
BrowserState doesn't include login automation, but you can pair it with your own Playwright/Selenium scripts.
Here’s a simple Playwright example using hardcoded credentials:
from browserstate import BrowserState, BrowserStateOptions
from playwright.async_api import async_playwright
state = BrowserState(BrowserStateOptions(
user_id="linkedin-user",
local_storage_path="./sessions"
))
async def login_and_capture():
session_id = "linkedin-session"
session_path = await state.mount(session_id)
async with async_playwright() as p:
browser = await p.chromium.launch_persistent_context(
user_data_dir=session_path,
headless=False
)
page = await browser.new_page()
await page.goto("https://www.linkedin.com/login")
await page.fill("#username", "you@example.com")
await page.fill("#password", "yourpassword")
await page.click("button[type='submit']")
await page.wait_for_url("https://www.linkedin.com/feed", timeout=10000)
await browser.close()
await state.unmount()
# asyncio.run(login_and_capture())
You can then reuse that session later without logging in again:
session_path = await state.mount("linkedin-session")
async with async_playwright() as p:
browser = await p.chromium.launch_persistent_context(
user_data_dir=session_path,
headless=True,
)
page = await browser.new_page()
await page.goto("https://www.linkedin.com/feed")
# Should already be logged in
🔄 Other Storage Providers
# S3
BrowserStateOptions(
user_id="agent123",
s3_options={
"bucket": "my-browserstate-bucket",
"aws_access_key_id": "...",
"aws_secret_access_key": "...",
"region_name": "us-west-2"
}
)
# Redis
BrowserStateOptions(
user_id="agent123",
redis_options={
"host": "localhost",
"port": 6379,
"key_prefix": "browserstate"
}
)
📚 Full API
await state.mount(session_id: str) -> str # Restores session
await state.unmount() -> None # Uploads & cleans up session
await state.list_sessions() -> List[str] # Lists all sessions
await state.delete_session(session_id: str) # Deletes from storage
state.get_current_session() -> Optional[str] # ID of mounted session
state.get_current_session_path() -> Optional[str]# Path to local session
🧪 Debugging & Reliability
BrowserState enables session capture after failed runs so you can:
- Reproduce bugs locally
- Test flows against known state
- Cache login sessions across tests or agents
📫 Stay Updated
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file browserstate-0.0.4.tar.gz.
File metadata
- Download URL: browserstate-0.0.4.tar.gz
- Upload date:
- Size: 13.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f023cd96c32e25218f32befd77477445485b198c64a5ea37b47376a79b514b1
|
|
| MD5 |
2ef2bf6c311ecbf3c44bd16dab6f2def
|
|
| BLAKE2b-256 |
4ecc8b53c9dc9ce8e6bb478a7c7a349434f37aa95a697f63b96672e47b422b37
|
File details
Details for the file browserstate-0.0.4-py3-none-any.whl.
File metadata
- Download URL: browserstate-0.0.4-py3-none-any.whl
- Upload date:
- Size: 17.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
209294b355cbcd404791ba10075d336169062cbebff239f64008cb11f87f4f4a
|
|
| MD5 |
184df7ccd70a8424a4a670197166bf46
|
|
| BLAKE2b-256 |
36f630f98319c49f2ee69c3f92a9bdedc28f32821ffe8ba623899298f9a82a95
|