Docs Get started
Quickstart
Add a video, create a watch, get an alert. Five minutes, with curl, JavaScript, Python and CLI.
You will give Percia a video, tell it what to look for, and read the alert it sends. You need a Percia account and one short video file at a public https address (or a phone or laptop to use as a camera).
In the app the same three steps look like this. If you prefer clicks to code, you can stop here and use the app.
The rest of this page does the same with the API.
1. Sign in and make an API key#
- Sign in at playground.percia.ai (email, Google, GitHub or Apple). Every account gets 10 free camera-minutes a month, no card.
- Open the API keys page in the app, create a key with the scopes
watches:read,watches:write,events:readandcameras:write, and copy it. It is shown once. Keys look likepk_live_....
export PERCIA_API_KEY=pk_live_...
export BASE=https://playground.percia.ai/api
curl -sS "$BASE/whoami" -H "Authorization: Bearer $PERCIA_API_KEY"whoami answers with the account the key belongs to. A 401 means the key is wrong.
2. Pick a source#
# Percia fetches a public https video (mp4, mov, webm or mkv) itself.
curl -sS -X POST "$BASE/uploads/from-url" -H "Authorization: Bearer $PERCIA_API_KEY" \
-H 'content-type: application/json' \
-d '{"url":"https://example.com/clip.mp4"}'
# -> {"uploadId":"...","source":"percia-file://<uploadId>", ...}# A device becomes a camera. Open pairUrl on it (single use, 10 minutes), allow the camera, press Start.
curl -sS -X POST "$BASE/cameras" -H "Authorization: Bearer $PERCIA_API_KEY" \
-H 'content-type: application/json' -d '{"name":"Hall camera"}'
# -> {"camera":{"id":"<cameraId>",...},"pairUrl":"https://.../cam/<token>"}
# the source is percia-cam://<cameraId># A public rtsp://, rtsps://, http:// or https:// video address works as it is.
# Nothing to create: use it as the source in step 3.Keep the value you get: percia-file://<uploadId>, percia-cam://<cameraId>, or your public link. That is the sourceUrl. A video file plays once and the watch ends when the video does.
3. Create a watch#
Leave notify out and the alert goes to your account email. To send it to your own server, add "notify": {"type":"webhook","target":"https://..."} (see Events and webhooks).
curl -sS -X POST "$BASE/watches/owned" -H "Authorization: Bearer $PERCIA_API_KEY" \
-H 'content-type: application/json' \
-d '{"sourceUrl":"percia-file://UPLOAD_ID","goal":"A person is walking in the frame"}'// npm install @percia/sdk
import { createClient } from "@percia/sdk";
const percia = createClient({ apiKey: process.env.PERCIA_API_KEY });
const watch = await percia.watches.create({
sourceUrl: "percia-file://UPLOAD_ID",
goal: "A person is walking in the frame",
});
console.log(watch.id, watch.status);# pip install percia
import os
from percia import Percia
client = Percia(api_key=os.environ["PERCIA_API_KEY"])
watch = client.watches.create({
"sourceUrl": "percia-file://UPLOAD_ID",
"goal": "A person is walking in the frame",
})
print(watch.id, watch.status)# npm install -g @percia/cli
percia login # opens a browser; or: percia login --with-key
percia watches create --source percia-file://UPLOAD_ID --goal "A person is walking in the frame"The answer is 201 with the watch id and status: "active". A new watch shows judging.state: "starting" for up to four minutes until its first frames arrive. That is normal.
The goal is read by Percia before the watch is made. If it is too vague you get 422 clarification_needed with a question and nothing is created (see Watches and goals).
4. Read the alert#
When the goal becomes true, Percia emails you (or posts to the destinations you attached). To read the same events from code:
curl -sS "$BASE/watches/WATCH_ID/events?limit=20" -H "Authorization: Bearer $PERCIA_API_KEY"for await (const event of percia.watches.iterateEvents(watch.id)) {
console.log(event.at, event.reason);
}for event in client.iter_watch_events(watch.id):
print(event.at, event.reason)percia events list --followEach event has the time, a reason written by the vision model, a confidence from 0 to 1, and a keyframe you can fetch.
5. Clean up#
curl -sS -X DELETE "$BASE/watches/WATCH_ID" -H "Authorization: Bearer $PERCIA_API_KEY"Deleting needs the watches:delete scope on the key.
Next#
- Send alerts to your server: Events and webhooks
- Send alerts to Slack, Discord, Telegram and more: Integrations
- Use a phone, a home camera or a bridge: Cameras
- How much it costs and what is free: Limits, pricing and credits
Stuck? Ask in the Percia Discord or email support@percia.ai. This page as Markdown: quickstart.md.