Vigiora

Tato stránka zatím není k dispozici v jazyce Čeština. Zobrazuje se v angličtině.

API quickstartOd verze 1.6.4

Your first API v1 calls with curl — list cameras, save a snapshot, acknowledge alerts in bulk, export a clip and download it, and share it with a public link.

This page walks through common tasks with curl. Replace yourname.vigiora.com with your site address (or http://<server-ip>:8080 on your local network) and the key with your own. jq is used to pick fields from the answers.

1. Get a key#

Create a key with the scopes these examples need. Sign in to get a session token, then create the key with it:

Terminal
BASE="https://yourname.vigiora.com"
 
TOKEN=$(curl -s -X POST "$BASE/api/auth/login" \
  -H "Content-Type: application/json" \
  -d '{"username":"automation","password":"example-password"}' | jq -r .access_token)
 
curl -s -X POST "$BASE/api/v1/api-keys" \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name":"Quickstart","scopes":["cameras:read","alerts:write","recordings:write","clips:share"],"expires_in_days":30}' \
  | jq -r .key

The last command prints the key, for example vgk_xxxxxxxx_xxxxxxxxxxxxxxxx. It is shown only once. Keep it in a variable for the next steps:

Terminal
KEY="vgk_xxxxxxxx_xxxxxxxxxxxxxxxx"

Check it:

Terminal
curl -s "$BASE/api/v1/me" -H "Authorization: Bearer $KEY"

See Authentication and scopes for what each scope allows. A key from Settings → People and access → API keys in the app also works, without clips:share.

2. List cameras#

Terminal
curl -s "$BASE/api/v1/cameras" -H "Authorization: Bearer $KEY" \
  | jq '.data[] | {id, name, status, ai_enabled}'
{ "id": 3, "name": "Front door", "status": "online", "ai_enabled": true }
{ "id": 4, "name": "Parking", "status": "offline", "ai_enabled": false }

Only cameras the key's user can view are listed. Add ?enabled=true or ?site_id=2 to filter. Lists come in pages; see Pagination.

3. Save a snapshot#

Terminal
curl -s "$BASE/api/v1/cameras/3/snapshot" -H "Authorization: Bearer $KEY" -o front-door.jpg

You get a current JPEG. If the camera can't produce one right now, a frame up to an hour old may be served, with its age in seconds in the Age header. Otherwise the answer is 503 snapshot_unavailable.

4. Acknowledge alerts in bulk#

List unacknowledged alerts of one camera:

Terminal
curl -s "$BASE/api/v1/alerts?camera_id=3&is_alert=true&acknowledged=false" \
  -H "Authorization: Bearer $KEY" | jq '.data[] | {id, label, detected_at}'

Acknowledge some of them by id (at most 500 at a time):

Terminal
curl -s -X POST "$BASE/api/v1/alerts/actions/acknowledge" \
  -H "Authorization: Bearer $KEY" \
  -H "Idempotency-Key: ack-2026-10-30-1" \
  -H "Content-Type: application/json" \
  -d '{"ids":[1201,1202,1203]}'
{ "acknowledged_count": 3, "not_found_ids": [], "forbidden_ids": [] }

Or acknowledge everything before a time, optionally on one camera:

Terminal
curl -s -X POST "$BASE/api/v1/alerts/actions/acknowledge" \
  -H "Authorization: Bearer $KEY" \
  -H "Content-Type: application/json" \
  -d '{"before":"2026-10-30T12:00:00Z","camera_id":3}'

Ids you can't see come back in not_found_ids; ids on cameras where you lack operator permission in forbidden_ids.

5. Export a clip and download it#

Ask for up to 30 minutes of a camera's recordings as one MP4. The answer is 202 with the export job:

Terminal
CLIP=$(curl -s -X POST "$BASE/api/v1/clips" \
  -H "Authorization: Bearer $KEY" \
  -H "Idempotency-Key: clip-front-door-1400" \
  -H "Content-Type: application/json" \
  -d '{"camera_id":3,"from":"2026-10-30T14:00:00Z","to":"2026-10-30T14:05:00Z"}' | jq -r .id)

Wait until it is ready:

Terminal
until [ "$(curl -s "$BASE/api/v1/clips/$CLIP" -H "Authorization: Bearer $KEY" | jq -r .status)" != "running" ]; do
  sleep 2
done

status ends as ready or failed (with the reason in error). Then get a download URL. It works once, for 60 seconds, without credentials:

Terminal
URL=$(curl -s -X POST "$BASE/api/v1/clips/$CLIP/actions/create-download-url" \
  -H "Authorization: Bearer $KEY" | jq -r .url)
curl -s "$BASE$URL" -o clip.mp4

Ready clips are kept for 24 hours, longer while a share link is live. GET /api/v1/clips lists your clips.

Anyone with the link can watch the clip, without signing in. It needs the clips:share scope:

Terminal
curl -s -X POST "$BASE/api/v1/clips/$CLIP/shares" \
  -H "Authorization: Bearer $KEY" \
  -H "Content-Type: application/json" \
  -d '{"expires_in":"24h"}' | jq '{id, url, expires_at}'
{ "id": 42, "url": "https://yourname.vigiora.com/s/xxxxxxxxxxxxxxxx", "expires_at": "2026-10-31T14:06:00Z" }

expires_in is 1h, 24h (default) or 7d, and a link never outlives the clip by more than 7 days. The URL is returned only here. A link made with a key also ends when the key is revoked or expires. Revoke it earlier with:

Terminal
curl -s -X DELETE "$BASE/api/v1/clips/$CLIP/shares/42" -H "Authorization: Bearer $KEY"

Next steps#

Upravit tuto stránku na GitHubu