Python SDK
The quin_camoufox Python package — install it, connect to the Local API, open and drive browsers, run RPA tasks and stream events.
quin_camoufox is the Python client of the Local API. It
has no third-party dependencies (Python standard library only), works with Python 3.10 or newer, and
installs the quin command line as well.
Install
The package is distributed as source with Quin Camoufox's developer materials (distribution name
quin-camoufox, version 0.7.0). Install it from its folder:
Download the Python SDK (it includes the quin command-line tool) from Developer downloads on the download page, check its SHA-256 like the installer's, then install it:
py -3 -m pip install .\{{quin.python_sdk}}Then turn on the Local API in Quin (Settings → Local API) and generate a token with the scopes your script needs.
Connect
from quin_camoufox import QuinClient
client = QuinClient("http://127.0.0.1:50380") # token from QUIN_API_TOKEN or `quin auth set-token`
status = client.status()
print(status["quin_version"], status["account"]["email"])The token is resolved in this order: the token= argument, the QUIN_API_TOKEN environment variable,
then the DPAPI-protected file written by quin auth set-token. It is never logged, and
repr(client) shows only the base URL.
QuinClient(base_url, token=None, *, timeout=30, action_timeout=120, max_retries=3, backoff=0.5, max_retry_after=30, allow_non_loopback=False)
base_urlmay end with or without/api/v1.- A non-loopback host is refused unless
allow_non_loopback=True(the API only listens on127.0.0.1anyway).
QuinClient.from_local_config(config_path=None, token=None, **kw) uses QUIN_API_URL if set, otherwise
reads the discovery file. It raises ApiUnavailable ("Quin Local API is not running: enable it in
Quin → Settings → Local API") when the file is missing.
Open a browser and act
from quin_camoufox import QuinClient, Locator
client = QuinClient.from_local_config()
with client.browsers.open(profile_id="AbCd1234", start_url="https://example.com") as session:
session.fill("input[name=q]", "camoufox")
session.click(Locator.role("button", name="Search"))
session.wait_for_url("**/search*")
print(session.title(), session.text("h1"))
rows = session.extract(item=".result", fields={"title": "h3", "url": {"selector": "a", "attr": "href"}})
shot = session.screenshot(full_page=True, name="search.png") # {"file", "bytes"} in the workspace
# leaving the block closes the browser; a Quin Cloud profile returns only once SYNCEDbrowsers.open(profile_id, start_url=None, *, wait=True, timeout_s=300, window=None, idempotency_key=None) returns a BrowserSession. With wait=False it returns at once; call
session.wait_ready(timeout_s) before acting.
BrowserSession
Properties: id, profile_id, state, kind, data, job_id. Methods: refresh(),
wait_ready(timeout_s=300), takeover(), close(sync=True, wait=True, timeout_s=900), and use as a
context manager.
Generic call: action(name, locator=None, tab=None, timeout_ms=None, **params) → ActionResult
(action, outcome, result, action_id, duration_ms, ok). An outcome of error raises
ActionError.
Helpers (each also accepts tab= and timeout_ms=):
| Group | Methods |
|---|---|
| Navigation | navigate(url, wait_until=None) (alias goto), reload(), back(), forward(), url(), title() |
| Elements | click(loc), dblclick(loc), right_click(loc), hover(loc), focus(loc), fill(loc, value), type(loc, text, delay_ms=None), clear(loc), press(key, locator=None), select(loc, values=None, labels=None), check(loc), uncheck(loc), scroll_into_view(loc), scroll_by(x=0, y=0), drag_to(loc, target), upload(loc, files), highlight(loc) |
| Waiting | wait_for(loc, state="visible"), wait_for_url(pattern), wait_for_load(state="load"), wait_for_text(text), wait_for_response(url_pattern, status=None) |
| Reading | text(loc), inner_html(loc), attribute(loc, name), value(loc), selected_values(loc), count(loc), is_visible(loc), is_enabled(loc), is_checked(loc), extract(fields, item=None, limit=None, locator=None), table(loc="table"), links(locator=None, limit=None) |
| Files | screenshot(full_page=False, name=None, locator=None), save_content(name), expect_download(trigger, save_as=None) |
| Tabs | tabs(), new_tab(url=None), switch_tab(tab), close_tab(tab=None), wait_for_popup(trigger), set_viewport(width, height), dialog_policy(accept, prompt_text=None) |
Locators
A string is a CSS selector. Locator builds the others: Locator.css(), .text(text, exact=None),
.role(role, name=None, exact=None), .label(), .placeholder(), .test_id(), .xpath(), then
.nth(i), .exact(), .has_text(text), .in_frame(selector) (call again for nested frames). A plain
dict such as {"role": "link", "name": "More"} works too.
Resources
| Attribute | Methods |
|---|---|
client.profiles | list(q, group_id, tag, kind, page=1, page_size=50, *, runtime_id, status), iter_all(page_size=200, **filters), get(id), create(name, *, group_id, tags, notes, configuration_id, proxy_id, os, idempotency_key), update(id, *, name, group_id, tags, notes), bulk(ids, set), clone_config(id, *, name, idempotency_key), trash(id), restore(id), revisions(id), sync_status(id), sync(id), runtime(id) |
client.groups | list(), create(name, **fields), update(id, **fields) |
client.proxies | list(), create(**fields), update(id, **fields), delete(id), assign(id, profile_ids), check(id) |
client.runtimes | list() |
client.configurations | list(q, os, page, page_size) |
client.browsers | open(...), list(), get(session_id), close(session_id, sync=True, wait=True, timeout_s=900), close_all(include_user=False), tabs(session_id) |
client.workflows | list(), get(id), create(workflow, *, idempotency_key), update(id, workflow), delete(id), publish(id, note=None), import_json(data, mode="new", preview=False), export(id) |
client.tasks | run(workflow_id, profile_ids=None, inputs=None, *, concurrency, group_id, filter, version, dataset, timeout_s, retries, error_policy, close_policy, idempotency_key) → Task, get(id), list(), cancel(id) |
client.runs | get(run_id) |
client.schedules | list(), create(**fields), update(id, **fields), delete(id) |
client.jobs | get(id) → Job, list(), cancel(id), wait(id, timeout=None) |
Also on the client: status(), openapi(), events(...). In update(), an omitted argument is left
unchanged and None clears the field. profiles.create(platform=…) sets the profile's platform (windows, macos or linux); os= is accepted as an
alias since 0.7.0-rc.4.
Run a workflow
import uuid
task = client.tasks.run("wf_123", profile_ids=["AbCd1234", "EfGh5678"], inputs={"query": "x"},
concurrency=2, idempotency_key=f"nightly-{uuid.uuid4()}")
task.wait(timeout=3600, poll_interval=2)
print(task.state)
for run in task.runs:
print(run["id"], run["profile_id"], run["state"], run.get("error_code"))Task and Job have id, state, data, error, refresh(), wait(timeout=None, poll_interval=1.0, raise_on_error=False) and cancel(); Task adds job_id and runs, Job adds
result. A wait that runs out raises QuinTimeout (wait_timeout).
Events
for event in client.events(kinds=["run.updated", "job.updated"]):
print(event.id, event.kind, event.data)events(kinds=None, last_event_id=None, *, reconnect=True, read_timeout=75, max_reconnect_delay=30, max_reconnects=None) yields Event(id, kind, data) and reconnects with Last-Event-ID.
Errors, retries and timeouts
Errors are QuinError subclasses — AuthError, PermissionDenied, NotFound, Conflict,
SessionBusy, InvalidRequest, RateLimited, ServerError, ActionError, QuinTimeout,
ApiUnavailable — with code, message, status, details. See Errors.
GETis retried on connection resets and502/503/504; other methods only when you passedidempotency_key. A429is retried on every method, honouringRetry-Afterup tomax_retry_afterseconds. At mostmax_retriesretries with exponential backoff.- HTTP timeout 30 s; actions
action_timeout(120 s) ortimeout_ms+ 15 s;browsers.opentimeout_s+ 30 s;closeup to 15 minutes, because a Quin Cloud save can be large.
asyncio
from quin_camoufox.aio import AsyncQuinClient
client = AsyncQuinClient.from_local_config()
async with await client.browsers.open(profile_id="AbCd1234") as session:
await session.navigate("https://example.com")
async for ev in client.events():
...The async client has the same API; each blocking call runs in a worker thread.
Examples
python_basic.py (list, open, navigate, title, screenshot, close) and python_rpa_task.py (run a
workflow with an idempotency key and wait) ship with the SDK examples. Both read QUIN_API_URL and
QUIN_API_TOKEN.