UniFi Protect API — event log.
Returns motion, ring, smartDetect, and recording events emitted by Protect cameras and other devices. Use this for security automation ("when the front door rings, do X") or for ad-hoc forensics ("what motion was detected last Tuesday around midnight?").
Requires cookie + CSRF authentication. See UnifiApi.Auth.Cookie.
Event fields
id,type—"motion","ring","smartDetectZone","smartAudioDetect","recording","package"start,end— unix millisecondsscore— confidence (0..100) for smart detectionscamera,cameraId— source devicesmartDetectTypes— list of"person","vehicle","animal","package","licensePlate"for smart eventsthumbnail,heatmap— opaque IDs to fetch viathumbnail/3(binary JPEG)
Summary
Functions
Returns a single event by id.
Lists events.
Returns Protect's system event log (firmware updates, NVR events, device adoption, etc. — distinct from camera events).
Returns the event thumbnail as a JPEG binary.
Functions
@spec get(Req.Request.t(), String.t()) :: {:ok, term()} | {:error, UnifiApi.Error.t()}
Returns a single event by id.
@spec list( Req.Request.t(), keyword() ) :: {:ok, term()} | {:error, UnifiApi.Error.t()}
Lists events.
Options
:start— window start, unix milliseconds.:end— window end, unix milliseconds.:types— filter to specific event types, list of strings.:cameras— filter to specific camera ids, list of strings.:limit— server-side cap.
Examples
# Last hour, motion only
hour_ago = (System.os_time(:millisecond) - 60 * 60 * 1000)
{:ok, events} = UnifiApi.Protect.Events.list(client,
start: hour_ago, types: ["motion", "smartDetectZone"], limit: 100)
@spec system_logs(Req.Request.t()) :: {:ok, term()} | {:error, UnifiApi.Error.t()}
Returns Protect's system event log (firmware updates, NVR events, device adoption, etc. — distinct from camera events).
@spec thumbnail(Req.Request.t(), String.t(), keyword()) :: {:ok, binary()} | {:error, UnifiApi.Error.t()}
Returns the event thumbnail as a JPEG binary.
Examples
{:ok, jpeg} = UnifiApi.Protect.Events.thumbnail(client, event_id)
File.write!("event.jpg", jpeg)