Docs Reference
SDKs and CLI
Install the JavaScript and Python SDKs and the percia command line, sign in, and see what each one covers.
All three are open source (MIT), generated from the same OpenAPI document as the API reference, and live in github.com/percia-ai/percia-sdks.
| Install | Package | |
|---|---|---|
| JavaScript and TypeScript | npm install @percia/sdk | @percia/sdk (latest) |
| Python 3.9+ | pip install percia | percia (latest) |
| Command line | npm install -g @percia/cli | @percia/cli (latest) |
Sign in#
import { createClient } from "@percia/sdk";
const percia = createClient({ apiKey: process.env.PERCIA_API_KEY }); // pk_live_...
// or an OAuth token: createClient({ oauthToken })
console.log(await percia.account.whoami()); // connection testimport os
from percia import Percia
client = Percia(api_key=os.environ["PERCIA_API_KEY"]) # or set PERCIA_API_KEY
print(client.account.whoami()) # connection test
# AsyncPercia is the async version with the same methodspercia login # browser sign-in (OAuth with PKCE)
percia login --with-key # or paste an API key at a hidden prompt
PERCIA_API_KEY=pk_live_... percia whoami # CI: the environment wins
percia doctor # checks your setupThe default API address is https://playground.percia.ai. Override it with baseUrl (JavaScript), base_url or PERCIA_BASE_URL (Python).
Common jobs#
// create, test, read, pause, delete
const watch = await percia.watches.create({
sourceUrl: "rtsp://cam.example.com/stream",
goal: "A person is standing at the front door",
notify: { type: "webhook", target: "https://example.com/hooks/percia" },
});
await percia.watches.testDelivery(watch.id);
for await (const e of percia.events.iterate({ type: "goal.met" })) console.log(e.at, e.reason);
await percia.watches.pause(watch.id);
await percia.watches.delete(watch.id);
// plan and free minutes
console.log(await percia.account.billing());watch = client.watches.create({
"sourceUrl": "rtsp://cam.example.com/stream",
"goal": "A person is standing at the front door",
"notify": {"type": "webhook", "target": "https://example.com/hooks/percia"},
})
client.watches.test_delivery(watch.id)
for e in client.iter_events(type="goal.met"):
print(e.at, e.reason)
client.watches.pause(watch.id)
client.watches.delete(watch.id)percia plan # free minutes left, credits, how you are charged
percia watches list
percia watches create --source rtsp://cam.example.com/stream --goal "A person is at the door" --email me@example.com
percia events list --follow # new events as they arrive
percia cameras add "Hall phone" # link and QR; then --source percia-cam://<id>
percia destinations connect slack # prints a link a person approves
percia listen --forward-to http://localhost:3000/hook
percia cameras push run --rtsp rtsp://user:pass@192.168.1.20/stream1 # needs ffmpeg 7.1+
percia mcp setup claude-codeThe CLI prints JSON with --json, exits with a code per kind of failure (3 not signed in or missing scope, 4 not found, 5 rate or plan limit, 6 network, 7 server), and shows each secret once.
What they cover#
The SDKs include retries, typed errors, pagination, webhook signature checking and an event stream. The latest SDK and CLI releases (0.5.0 and later) cover all 171 operations in the API, including the six Live operations, generated from the same OpenAPI document. If a call from the API reference is missing in the version you installed, update the package or call the HTTP API directly.
In JavaScript every covered operation is also available by its operationId as percia.api.<operationId>(options), which returns { data, error, response } without throwing. percia.raw is the generated client.
Postman and examples#
- A Postman collection, environment and an Insomnia export are in the repository's
postman/folder. examples/has webhook receivers (Express, Cloudflare Workers, FastAPI, Go, Ruby), a Slack script, a voice alert and a GitHub Actions example.
Stuck? Ask in the Percia Discord or email support@percia.ai. This page as Markdown: sdks.md.