JavaScript SDK
The @quin/camoufox-local TypeScript SDK for Node.js — connect to the Quin Local API, drive browsers, run RPA tasks and stream events.
@quin/camoufox-local is the TypeScript/JavaScript client of the
Local API for Node.js 18 or newer. It has no runtime
dependencies (it uses Node's built-in fetch) and ships its own type definitions.
Install
The SDK is distributed as source with Quin Camoufox's developer materials (version 0.7.0). Build it
once, then import it from its dist folder or pack it into your project:
Download the TypeScript/JavaScript SDK package from Developer downloads on the download page, check its SHA-256, then add it to your project:
npm install .\{{quin.js_sdk}}The package is an ES module (import). From CommonJS, require() works on Node 22.12 and newer; on
older Node use await import("@quin/camoufox-local").
Connect
import { QuinClient } from "@quin/camoufox-local";
const client = new QuinClient({ baseUrl: "http://127.0.0.1:50380" }); // token from QUIN_API_TOKEN
const status = await client.status();
console.log(status.quin_version, status.account.email);new QuinClient(options):
| Option | Default | Notes |
|---|---|---|
baseUrl | required | With or without /api/v1; a non-loopback host is refused unless allowNonLoopback: true |
token | process.env.QUIN_API_TOKEN | The JS SDK does not read the file stored by quin auth set-token |
timeoutMs | 30000 | HTTP timeout |
actionTimeoutMs | 120000 | For actions without timeoutMs |
maxRetries | 3 | |
backoffMs | 500 | Exponential backoff base |
maxRetryAfterMs | 30000 | Longest Retry-After honoured |
signal | – | An AbortSignal that cancels every request of this client |
QuinClient.fromLocalConfig({ configPath?, ...options }) uses QUIN_API_URL if set, otherwise the
discovery file; a missing file throws ApiUnavailable.
Open a browser and act
import { QuinClient, Locator, ActionError } from "@quin/camoufox-local";
const client = QuinClient.fromLocalConfig();
const browser = await client.browsers.open({ profileId: "AbCd1234", timeoutS: 300 });
try {
const nav = await browser.navigate("https://example.com", { waitUntil: "load" });
console.log(nav.status, await browser.title(), await browser.text("h1"));
await browser.click(Locator.role("link", "More information"));
const shot = await browser.screenshot({ fullPage: true, name: "example.png" });
console.log(shot.file, shot.bytes);
} catch (err) {
if (err instanceof ActionError) console.error(err.action, err.code, err.message);
else throw err;
} finally {
await browser.close({ sync: true }); // resolves at SYNCED for a Quin Cloud profile
}browsers.open({ profileId, startUrl?, window?, wait?, timeoutS?, idempotencyKey? }) returns a
BrowserSession; timeoutS defaults to 300. With wait: false call await session.waitReady() before
acting. browsers.withSession(options, fn) opens, runs fn and always closes with sync.
browsers.session(id) makes a handle for a known session id without a request.
BrowserSession
Getters id, profileId, state, kind, plus data and jobId. Methods refresh(),
waitReady({ timeoutS?, pollIntervalMs? }), takeover(), close({ sync?, wait?, timeoutS? }).
Generic call: action(name, { locator?, params?, tab?, timeoutMs? }) with snake_case params, as on
the wire. Helpers take an options object last ({ tab?, timeoutMs? } plus their own options):
| Group | Methods |
|---|---|
| Navigation | navigate(url, { waitUntil }), reload(), back(), forward(), url(), title() |
| Elements | click(loc, { position, modifiers }), dblclick(loc), rightClick(loc), hover(loc), focus(loc), fill(loc, value), type(loc, text, { delayMs }), clear(loc), press(key, { locator }), select(loc, { values } | { labels }), check(loc), uncheck(loc), scrollIntoView(loc), scrollBy(x, y), dragTo(loc, target), upload(loc, files), highlight(loc) |
| Waiting | waitFor(loc, { state }), waitForUrl(pattern), waitForLoad(state), waitForText(text), waitForResponse(urlPattern, { status }) |
| Reading | text(loc), innerHtml(loc), attribute(loc, name), value(loc), selectedValues(loc), count(loc), isVisible(loc), isEnabled(loc), isChecked(loc), extract({ fields, item?, limit?, locator? }), table(loc = "table"), links({ locator?, limit? }) |
| Files | screenshot({ fullPage?, name?, locator? }), saveContent(name), expectDownload(trigger, { saveAs }) |
| Tabs | tabs(), newTab(url?), switchTab(tab), closeTab(tab?), waitForPopup(trigger), setViewport(width, height), dialogPolicy(accept, promptText?) |
Locators
A string is a CSS selector. Builders: Locator.css(), Locator.text(text, exact?),
Locator.role(role, name?, exact?), Locator.label(), Locator.placeholder(), Locator.testId(),
Locator.xpath(), then .nth(i), .exact(), .hasText(text), .inFrame(selector). Plain objects
such as { role: "button", name: "Save" } work too.
Resources
| Property | Methods |
|---|---|
client.profiles | list({ q, groupId, tag, kind, runtimeId, status, page, pageSize }), iterAll(filters) (async generator), get(id), create(body, { idempotencyKey }), update(id, fields), bulk(ids, set), cloneConfig(id, { name, idempotencyKey }), trash(id), restore(id), revisions(id), syncStatus(id), sync(id), runtime(id) |
client.groups | list(), create(body), update(id, fields) |
client.proxies | list(), create(body), update(id, fields), delete(id), assign(id, profileIds), check(id) |
client.runtimes | list() |
client.configurations | list({ q, os, page, pageSize }) |
client.browsers | open(o), withSession(o, fn), list(), get(id), session(id), close(id, opts), closeAll({ includeUser }), tabs(id) |
client.workflows | list(), get(id), create(workflow, { idempotencyKey }), update(id, workflow), delete(id), publish(id, note?), importJson(data, { mode, preview }), export(id) |
client.tasks | run({ workflowId, profileIds, groupId, filter, version, inputs, dataset, concurrency, timeoutS, retries, errorPolicy, closePolicy, idempotencyKey }) → Task, get(id), list(), cancel(id) |
client.runs | get(id) |
client.schedules | list(), create(body), update(id, fields), delete(id) |
client.jobs | get(id) → Job, list(), cancel(id), wait(id, { timeoutMs, pollIntervalMs, raiseOnError }) |
Request bodies of create/update use the API's snake_case field names (group_id, proxy_id).
profiles.create() takes the profile's platform (os is accepted as an alias since 0.7.0-rc.4).
Run a workflow
const task = await client.tasks.run({
workflowId: "wf_123", profileIds: ["AbCd1234"], inputs: { query: "x" },
idempotencyKey: `nightly-${Date.now()}`,
});
await task.wait({ timeoutMs: 3_600_000, pollIntervalMs: 2000 });
console.log(task.state, task.runs.map((r) => r.state));Task and Job expose id, state, data, done, refresh(), wait({ timeoutMs?, pollIntervalMs?, raiseOnError? }) and cancel(); Task adds jobId and runs, Job adds result.
Events
const ac = new AbortController();
for await (const ev of client.events({ kinds: ["browser.closed", "job.updated"], signal: ac.signal })) {
console.log(ev.id, ev.kind, ev.data);
}events({ kinds?, lastEventId?, reconnect?, readTimeoutMs?, maxReconnectDelayMs?, maxReconnects?, signal? }) reconnects with Last-Event-ID; abort the signal to stop.
Errors, cancellation and retries
Errors are QuinError subclasses — AuthError, PermissionDenied, NotFound, Conflict,
SessionBusy, InvalidRequest, RateLimited (retryAfter), ServerError, ActionError
(action, actionId, durationMs), QuinTimeout, ApiUnavailable — with code, message,
status, details. See Errors.
An aborted signal rejects with code cancelled and is never retried. Cancelling the HTTP call does not
stop work Quin already accepted: use jobs.cancel() or tasks.cancel(). Requests without an
idempotency key are retried only after a 429; GET is also retried on network errors and
502/503/504.
The example node_basic.mjs (list, open, navigate, title, screenshot, close) ships with the SDK
examples.