Integrating external video analytics¶
An external system receives camera video, detects events and sends them to the surveillance system. Choose the contract according to the result to store:
- An event with an interval and description — create a
genericepisode through Watcher Client API. This requires a Watcher user token and camera editing permission. Watcher assigns the episode ID. - A typed vehicle or face event — use the Central service contract with separate Central authentication. The integration assigns the ID and sends its own analytics results. A
vehicleexample follows.
Creating generic does not recognize a face or plate or create a built-in analytics result of that type. Sending face through Central does not itself trigger identification by fingerprint. These operations store external results.
RTSP for analytics¶
Provide analytics with a separate viewing token for the specific camera, following RTSP access. To send generic episodes through Client API, use a separate Watcher account permitted to edit the required cameras and API authentication.
Synchronize the video source and external analytics clocks. Episode API times use Unix milliseconds; HTTP request arrival time does not replace the event time in video.
Generic episodes through Watcher Client API¶
Create an episode with:
POST /watcher/client-api/v3/episodes
Authorization: Bearer <token>
Content-Type: application/json
{
"media": "entrance-example",
"opened_at": 1793692800000,
"closed_at": 1793692810000,
"title": "External sensor event",
"description": "Motion at entrance"
}
Replace media with the camera name returned by the API. Creation requires camera editing permission; viewing alone is insufficient.
Request fields:
- media — required camera name.
- opened_at — required episode start, in Unix milliseconds.
- closed_at — optional end in the same units.
- title — up to 64 characters.
- description — up to 256 characters.
- preview — optional Base64-encoded JPEG. Send Base64 only, without
data:image/jpeg;base64,: the web interface adds this prefix itself.
Prepare preview from a JPEG file using Python:
import base64
from pathlib import Path
preview = base64.b64encode(Path("preview.jpg").read_bytes()).decode("ascii")
Place the value in the JSON body's preview field. The backend stores the string without conversion, so first verify the source file is a valid JPEG.
Save episode_id from the response. Another POST creates a new episode, so the external system must account for already stored results when retrying delivery.
To edit text, substitute the saved response's episode_id in the URL:
PUT /watcher/client-api/v3/episodes/{episode_id}
Authorization: Bearer <token>
Content-Type: application/json
{"title":"Reviewed event","description":"Operator comment"}
This changes title and description. It does not extend a detection interval or resend a complete built-in analytics object.
Generic episode IDs¶
Watcher assigns the ID when creating generic through Client API. It uses opened_at and selects another value if that ID is occupied. The integration does not need to generate a Snowflake ID. Always save the actual response's episode_id for reading and updates.
Verify a generic episode¶
- Confirm the test account may edit the selected camera.
- Create an episode whose interval matches existing camera recordings.
- Read it through
GET /watcher/client-api/v3/episodes/{episode_id}or find it in Watcher's episode section. - Check the title and description, then open video for the specified interval.
- Test a viewing-only account: creation must be denied.
An episode's existence does not prove recording exists for its interval. Playback requires archive recording to be enabled and the user to have access.
Vehicle events through Central¶
The service contract PUT /central/api/v3/episodes/{episode_id} is also available under /streamer/api/v3. It accepts typed face and vehicle data; existing IDs use JSON merge-patch. This example uses vehicle.
Use your Central API address and a separate Central key. The example sends Bearer <central_api_key>. A Central administrator issues the key; alternatively, a Central service token with read/write permissions and episode scope can be used. A Watcher user's access_token does not provide this access.
The integration assigns a unique integer episode_id in the URL. Save and reuse it for updates to this event. Replace the fictitious example values with your data:
PUT /central/api/v3/episodes/1793692800000001
Authorization: Bearer <central_api_key>
Content-Type: application/json
{
"episode_type": "vehicle",
"media": "entrance-example",
"opened_at": 1793692800000,
"started_at": 1793692800000,
"closed_at": 1793692810000,
"updated_at": 1793692811000,
"license_plate_text": "A000AA00",
"license_plate_missing": false,
"vehicle_purpose": "regular"
}
media is the existing camera's technical name from Watcher API, not its display title. All times are Unix milliseconds. A new event requires media, opened_at and updated_at; the type here is vehicle. The integration assigns the path ID; it is not a time field. On save, Central assigns its own monotonic updated_at for update retrieval.
Optional preview and frame_preview contain prepared JPEGs encoded as Base64 without data:image/jpeg;base64,: the object thumbnail and whole frame respectively. Images and plate text come from the external system. Sending them does not trigger Watcher OCR.
After a successful PUT, read the event with the same Central key:
GET /central/api/v3/episodes/1793692800000001
Authorization: Bearer <central_api_key>
Success returns HTTP 200. Check episode_type, media, interval and license_plate_text. To correct the plate, send a partial update to the same address:
PUT /central/api/v3/episodes/1793692800000001
Authorization: Bearer <central_api_key>
Content-Type: application/json
{"license_plate_text":"A001AA00"}
Repeat GET: the number should change. Check that episode_type, media, opened_at and closed_at remain; Central updates its own updated_at on save.
After Watcher processes the event, check it through Client API, now using a Watcher user token with access to this camera's episodes:
GET /watcher/client-api/v3/episodes/1793692800000001
Authorization: Bearer <watcher_user_token>
Check the type, camera name and updated plate. If the event is absent, read again after updates are processed and check Watcher–Central connectivity and user permissions. Watcher stores selected event data; successful reading does not mean the whole original structure was transferred, face identification ran or an archive exists for the interval.