Python Examples
Choose a runnable Python quickstart script by browser task.
The maintained scripts live in the Python quickstart repository. Clone that repository when you need runnable examples; this page is the map, not a second copy of every script.
Setup
git clone https://github.com/lexmount/lexmount-python-sdk-quickstart.git
cd lexmount-python-sdk-quickstart
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
playwright install chromium
cp .env.example .envFill LEXMOUNT_API_KEY and LEXMOUNT_PROJECT_ID in .env before running a script.
Start here
| Script | Purpose |
|---|---|
demo.py | Minimal Chromium session, Playwright connection, navigation, and screenshot |
light_demo.py | Moli (light) session and LightMount resource switch |
inspect_url_demo.py | Print View URL and keep the session open for manual inspection |
session_list.py | List active and historical sessions with pagination |
session_targets.py | Query page targets, View URLs, and websocket URLs |
session_downloads.py | Trigger, list, retrieve, archive, and clear stored downloads |
Run:
python3 demo.py
python3 light_demo.py
python3 inspect_url_demo.pyPersistent state and extensions
| Script | Purpose |
|---|---|
context_basic.py | Create a described context and use it in a read-write session |
context_list_get.py | List contexts and inspect display name, description, and status |
context_fork.py | Fork an available context into a new context |
extension_basic.py | Upload, list, and mount an extension |
extension_list_get.py | List/get extensions and optionally upload/delete one |
Network, region, and connection
| Script | Purpose |
|---|---|
catalog_info.py | Inspect the public region and endpoint catalog |
connection_demo.py | Build and use the direct /connection websocket URL |
proxy_demo.py | Use an authenticated custom upstream proxy |
official_proxy_demo.py | Use the Lexmount official proxy pool |
Runtime shape and diagnostics
| Script | Purpose |
|---|---|
custom_image_demo.py | Start an approved custom browser image |
window_size_demo.py | Set the initial browser size |
wpt_demo.py | Run a Web Platform Tests path across one or more sessions |
cpu_load_demo.py | Generate controlled multi-page browser load for diagnostics |
Examples that use custom images, proxies, contexts, or extensions require the corresponding project capability.
Safe cleanup
Prefer the SDK context manager pattern in your own scripts:
from lexmount import Lexmount
with Lexmount() as client:
with client.sessions.create() as session:
# Browser work
...Before rerunning a failed example, inspect the console session list. Async create can reserve a session before the client sees a timeout.
Lexmount Browser