{"openapi":"3.0.0","info":{"title":"ExNVR API","description":"Manage ExNVR via API endpoints","version":"0.29.0"},"servers":[{"url":"http://localhost:4000","description":"ExNVR API (ex-nvr)"}],"paths":{"/api/users/login":{"post":{"summary":"Login user","description":"Login the user into the system\n\nThe issued access token has a validity of `2 days`.\n","operationId":"login","tags":["User"],"security":[],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"username":{"type":"string","format":"email"},"password":{"type":"string","format":"password"}},"required":["username","password"]}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"access_token":{"type":"string","description":"An access token to use to authorize subsequent requests"}}}}}},"400":{"$ref":"#/components/responses/BadArg"}}}},"/api/users":{"get":{"summary":"Get all users.","description":"Get all existing users.","operationId":"getUsers","tags":["User"],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/User"}}}}}}},"post":{"summary":"Create user","description":"Create a new user.\n","operationId":"createUser","tags":["User"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"first_name":{"type":"string","description":"User first name"},"last_name":{"type":"string","description":"User last name"},"email":{"type":"string","description":"User email"},"role":{"type":"string","enum":["admin","user"],"default":"admin","description":"User's role.\n\n* `admin` - Has access to all features.\n* `user` - Has only \"read\" access to devices, recordings as well as streaming features.\n  Does not have access to Onvif Discovery and users management.\n"},"language":{"type":"string","enum":["en"],"default":"en","description":"User's application language.\n\n* Only english available for now.\n"}},"required":["first_name","last_name","email"]}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/User"}}}},"400":{"$ref":"#/components/responses/BadArg"},"403":{"$ref":"#/components/responses/Unauthorized"}}}},"/api/users/{user_id}":{"parameters":[{"$ref":"#/components/parameters/user_id"}],"get":{"summary":"Get user","description":"Get user by id.","operationId":"getUser","tags":["User"],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/User"}}}},"403":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}},"put":{"summary":"Update user","description":"Update user details.\n","operationId":"updateUser","tags":["User"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"first_name":{"type":"string","description":"User first name"},"last_name":{"type":"string","description":"User last name"},"email":{"type":"string","description":"User email"},"role":{"type":"string","enum":["admin","user"],"default":"admin","description":"User's role.\n\n* `admin` - Has access to all features.\n* `user` - Has only \"read\" access to devices, recordings as well as streaming features.\n  Does not have access to Onvif Discovery and users management.\n"},"language":{"type":"string","enum":["en"],"default":"en","description":"User's application language.\n\n* Only english available for now.\n"}}}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/User"}}}},"400":{"$ref":"#/components/responses/BadArg"},"403":{"$ref":"#/components/responses/Unauthorized"}}},"delete":{"summary":"Delete user","description":"Delete a user giving the user id\n\nAll associated will be removed along the user's deletion.\n","operationId":"deleteUser","tags":["User"],"responses":{"204":{"description":"Success"},"403":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/api/remote_storages":{"get":{"summary":"Get all remote storages.","description":"Get all existing remote storages.","operationId":"getRemoteStorages","tags":["RemoteStorage"],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/RemoteStorage"}}}}}}},"post":{"summary":"Create a remote storage.","description":"Create a new remote storage.\n","operationId":"createRemoteStorage","tags":["RemoteStorage"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","description":"Remote Storage name"},"url":{"type":"string","description":"Remote Storage url"},"type":{"type":"string","enum":["s3","http"],"description":"The type of the remote storage."},"s3_config":{"$ref":"#/components/schemas/S3Config"},"http_config":{"$ref":"#/components/schemas/HttpConfig"}},"required":["name","url","type"]}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RemoteStorage"}}}},"400":{"$ref":"#/components/responses/BadArg"},"403":{"$ref":"#/components/responses/Unauthorized"}}}},"/api/remote_storages/{remote_storage_id}":{"parameters":[{"$ref":"#/components/parameters/remote_storage_id"}],"get":{"summary":"Get remote storage","description":"Get remote storage by id.","operationId":"getRemoteStorage","tags":["RemoteStorage"],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RemoteStorage"}}}},"403":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}},"put":{"summary":"Update a Remote Storage","description":"Update Remote Storage details.\n","operationId":"updateRemoteStorage","tags":["RemoteStorage"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string","description":"Remote Storage url"},"s3_config":{"$ref":"#/components/schemas/S3Config"},"http_config":{"$ref":"#/components/schemas/HttpConfig"}}}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/RemoteStorage"}}}},"400":{"$ref":"#/components/responses/BadArg"},"403":{"$ref":"#/components/responses/Unauthorized"}}},"delete":{"summary":"Delete a remote storage","description":"Delete a remote storage identified by the provided id.\n","operationId":"deleteRemoteStorage","tags":["RemoteStorage"],"responses":{"204":{"description":"Success"},"403":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/api/devices":{"get":{"summary":"Get all devices.","description":"Get all existing devices.","operationId":"getDevices","tags":["Device"],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Device"}}}}}}},"post":{"summary":"Create device","description":"Create a new device.\n\nOnce the device is created, a pipeline will be started and will attempt to connect and\nretrieve a stream from it.\n","operationId":"createDevice","tags":["Device"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","description":"Device name"},"type":{"type":"string","enum":["ip","file"],"description":"Device type"},"vendor":{"type":"string","description":"Device vendor"},"mac":{"type":"string","description":"Device mac address"},"url":{"type":"string","description":"Device url"},"model":{"type":"string","description":"Device model"},"timezone":{"type":"string","description":"Device timezone","default":"UTC"},"state":{"type":"string","enum":["recording","stopped"],"default":"recording","description":"Initial state of the device.\n\n* `recording` - The device will attempt connecting and recording videos\non creation\n* `stopped` - The device will be created and will not try to connect or record\nvideos.\n"},"stream_config":{"$ref":"#/components/schemas/StreamConfig"},"credentials":{"$ref":"#/components/schemas/Credentials"},"settings":{"$ref":"#/components/schemas/DeviceSettings"},"storage_config":{"$ref":"#/components/schemas/DeviceStorageConfig"},"snapshot_config":{"$ref":"#/components/schemas/DeviceSnapshotConfig"}},"required":["name","type","storage_config"]}}}},"responses":{"201":{"description":"Created","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Device"}}}},"400":{"$ref":"#/components/responses/BadArg"},"403":{"$ref":"#/components/responses/Unauthorized"}}}},"/api/devices/{device_id}":{"parameters":[{"$ref":"#/components/parameters/device_id"}],"get":{"summary":"Get device","description":"Get device by id.","operationId":"getDevice","tags":["Device"],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Device"}}}},"404":{"$ref":"#/components/responses/NotFound"}}},"put":{"summary":"Update device","description":"Update device details.\n\nIf the device config (e.g. `stream_config`) is updated, the pipeline is restarted\nto pick up the new configuration.\n","operationId":"updateDevice","tags":["Device"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"name":{"type":"string","description":"Device name"},"vendor":{"type":"string","description":"Device vendor"},"mac":{"type":"string","description":"Device mac address"},"url":{"type":"string","description":"Device url"},"model":{"type":"string","description":"Device model"},"timezone":{"type":"string","description":"Device timezoned","default":"UTC"},"state":{"type":"string","enum":["recording","stopped"],"default":"recording","description":"Initial state of the device.\n\n* `recording` - The device will attempt connecting and recording videos\non creation\n* `stopped` - The device will be created and will not try to connect or record\nvideos.\n"},"stream_config":{"$ref":"#/components/schemas/StreamConfig"},"credentials":{"$ref":"#/components/schemas/Credentials"},"settings":{"$ref":"#/components/schemas/DeviceSettings"},"storage_config":{"$ref":"#/components/schemas/DeviceStorageConfig"},"snapshot_config":{"$ref":"#/components/schemas/DeviceSnapshotConfig"}}}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Device"}}}},"400":{"$ref":"#/components/responses/BadArg"},"403":{"$ref":"#/components/responses/Unauthorized"}}},"delete":{"summary":"Delete device","description":"Delete a device giving the device id\n\nThe actual recording files are not deleted.\nIf you want to delete them delete the folder:\n\n  `{device.settings.storage_address}/ex_nvr/{device.id}`\n","operationId":"deleteDevice","tags":["Device"],"responses":{"204":{"description":"Success"},"403":{"$ref":"#/components/responses/Unauthorized"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/api/recordings/chunks":{"get":{"summary":"Get recordings chunks","description":"Get all the recorded videos chunks order by decreasing start date.\n","operationId":"getRecordingChunks","tags":["Recording"],"parameters":[{"$ref":"#/components/parameters/stream_type"},{"$ref":"#/components/parameters/filters"},{"$ref":"#/components/parameters/page"},{"$ref":"#/components/parameters/page_size"},{"$ref":"#/components/parameters/order_by"},{"$ref":"#/components/parameters/order_directions"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"data":{"type":"array","items":{"$ref":"#/components/schemas/Recording"}},"meta":{"$ref":"#/components/schemas/ResultMeta"}}}}}},"400":{"$ref":"#/components/responses/BadArg"}}}},"/api/devices/{device_id}/recordings":{"get":{"summary":"Get recordings","description":"Get all dates where there's available footages","operationId":"getRecordings","tags":["Recording"],"parameters":[{"$ref":"#/components/parameters/device_id"},{"$ref":"#/components/parameters/stream_type"},{"name":"start_date","in":"query","required":false,"description":"Filter by start date","schema":{"type":"string","format":"date-time"},"example":"2023-01-15T10:00:01Z"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"array","items":{"type":"object","properties":{"start_date":{"type":"string","format":"date-time","description":"The start date of the run"},"end_date":{"type":"string","format":"date-time","description":"The end date of the run"},"active":{"type":"boolean","description":"`true` if this an active run (still recording), `false` otherwise\n"}}}}}}},"400":{"$ref":"#/components/responses/BadArg"}}}},"/api/devices/{device_id}/recordings/{recording_id}/blob":{"get":{"summary":"Get recording blob","description":"Download the video chunk with the specified `recording id` in the specified `device`\n","operationId":"getRecordingBlob","tags":["Recording"],"parameters":[{"$ref":"#/components/parameters/device_id"},{"$ref":"#/components/parameters/recording_id"},{"$ref":"#/components/parameters/stream_type"}],"responses":{"200":{"description":"Success","content":{"video/mp4":{"schema":{"type":"string","format":"binary"}}}},"400":{"description":"Not found","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string","description":"The error message"}}}}}}}}},"/api/devices/{device_id}/hls/index.m3u8":{"get":{"summary":"Start HLS streaming","description":"Start HLS live view streaming or playback of recorded videos.\n\nBy default, there'll be no transcoding since we currently only support H264, the stream is\nmuxed as it is into fMP4 files.\n\nIf the device has sub stream provided, the manifest will also contain the lower resolution.\n\nFor playback, only the high resolution stream can be provided, since we don't support storing\nsub-streams to file system.\n\n## Stream Selection\n\nif the `stream` query parameter is provided, only the requested stream will be included in the\nmanifest.\n\nNote that we don't do any checks on the existence of the requested stream (e.g. if you\nrequest the sub stream and the device has no sub stream, then you'll get an empty manifest).\n","operationId":"startHlsStreaming","tags":["Media Streaming"],"parameters":[{"$ref":"#/components/parameters/device_id"},{"$ref":"#/components/parameters/stream_type"},{"name":"pos","in":"query","description":"Start streaming from the given date time.\n\nIf this `param` is provided, only high quality is enabled\n","schema":{"type":"string","format":"date-time"}},{"duration":null,"in":"query","description":"Set the duration of the stream.\n\n0 means no duration.\n","default":0,"schema":{"type":"integer"}},{"name":"resolution","in":"query","description":"The resolution (height) of the video, defaults to `nil`. If provided the video will be\ntrancoded.\n\nTranscoding is a CPU intensive operation.\n","schema":{"type":"integer","enum":[240,480,640,720,1080]}}],"responses":{"200":{"description":"Success","content":{"application/vnd.apple.mpegurl":{"schema":{"type":"string"}}}}}}},"/api/devices/{device_id}/snapshot":{"get":{"summary":"Get snapshot","description":"Get a snapshot from live feed or the recorded videos.\n","operationId":"getSnapshot","tags":["Media Streaming"],"parameters":[{"$ref":"#/components/parameters/device_id"},{"name":"time","in":"query","required":false,"description":"Timestamp of the requested snapshot.\n\nA missing or `null` value means `now`, the latest snapshot from the live feed.\n","schema":{"type":"string","format":"date-time"},"example":"2023-10-10T10:00:00Z"},{"name":"method","in":"query","required":false,"description":"Getting a snapshot at the exact timestamp is costly, so, it can be rounded\nto the nearest keyframe, thus, the default value is \"before\".\n\nPossible values are:\n  * `before` - Get the snapshot from the nearest keyframe before the requested timestamp.\n  * `precise` - Get the snapshot as near as possible from the requested timestamp.\n","schema":{"type":"string","enum":["before","precise"]}},{"name":"format","in":"query","required":false,"description":"Image format","schema":{"type":"string","enum":["jpeg"]}},{"$ref":"#/components/parameters/stream_type"}],"responses":{"200":{"description":"success","headers":{"x-timestamp":{"schema":{"type":"integer"},"description":"Timestamp of the snapshot in milliseconds since unix epoch."}},"content":{"image/jpeg":{"schema":{"type":"string","format":"byte"}}}},"400":{"$ref":"#/components/responses/NotFound"}}}},"/api/devices/{device_id}/footage":{"get":{"summary":"Download video footage","description":"Download footages in the `mp4` format up to a maximum of 2 hours.\n\n### Duration and End date\n\nIn addition to the query parameter `start_date` which is required, either `end_date`\nor `duration` should be provided.\n\nIf the `end_date` is provided, the total time between `start_date` and `end_date` should be within\n2 hours.\n\n### Downloaded Footage Start Date\n\nNote that for this endpoint to be efficient, there's no transcoding done\nto the recorded footage. So the start date of the downloaded video may not\nbe the same as the requested one through `start_date` since we need to\nstart the footage from the nearest keyframe before the provided start date.\n\n### Recording Discontinuity\n\nA discontinuity in the recorded videos may be present due to several reasons (e.g. lost\nconnection to the camera, NVR reboot, ...etc.). In this case the video duration may not be\nthe one expected.\n\nIn the case `end_date` is provided, the interval between `start_date` and `end_date` will be greater\nor equal to the duration of the downloaded video\n\nIn the case `duration` is provided, the end date reported in the downloaded video may be far from\nthe `start_date + duration`.\n","operationId":"downloadFootage","tags":["Media Streaming"],"parameters":[{"$ref":"#/components/parameters/device_id"},{"$ref":"#/components/parameters/stream_type"},{"name":"start_date","in":"query","required":true,"description":"Start date of the footage.\n","schema":{"type":"string","format":"date-time"}},{"name":"end_date","in":"query","required":false,"description":"The end date of the footage.\n\nIf `end_date` and `duration` is provided, the first condition\nthat's met will end the video footage.\n","schema":{"type":"string","format":"date-time"}},{"name":"duration","in":"query","required":false,"description":"The duration of the footage in seconds.\n\nIf `end_date` and `duration` is provided, the first condition\nthat's met will end the video footage.\n","schema":{"type":"integer","minimum":5,"maximum":7200}}],"responses":{"200":{"description":"success","headers":{"x-start-date":{"schema":{"type":"integer"},"description":"Since the video must start from the nearest keyframe before the requested start date.\n\nThis header reports the actual start date in milliseconds unix timestamp.\n"}},"content":{"video/mp4":{"schema":{"type":"string","format":"binary"}}}},"400":{"$ref":"#/components/responses/BadArg"}}}},"/api/devices/{device_id}/bif/{hour}":{"get":{"summary":"Download BIF file","description":"Download [BIF](https://developer.roku.com/en-gb/docs/developer-program/media-playback/trick-mode/bif-file-creation.md) (Base Index Frames) files.\n\n`BIF` files are used for trick mode (play) and generated perdiocally on a 1-hour increments, therefore\nthey're not available for live content or content that's not older than one hour.\n","operationId":"downloadBif","tags":["Media Streaming"],"parameters":[{"$ref":"#/components/parameters/device_id"},{"name":"hour","in":"path","required":true,"description":"The hour of the BIF file.\n","schema":{"type":"string","format":"date-time","example":"2023-08-31T13:00:00Z"}}],"responses":{"200":{"description":"success","content":{"application/octet-stream":{"schema":{"type":"string","format":"byte"}}}},"400":{"$ref":"#/components/responses/BadArg"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/api/onvif/discover":{"post":{"summary":"Onvif discovery","description":"Scan the local network for Onvif compliant devices.\n\nThe following information are retrieved from the devices:\n\n  * The url, name and hardware.\n  * Date time settings\n  * Basic information about the device (vendor, model, firware version, ...etc.)\n\nMost of the operations above needs authentication, so if a `username` and `password` are not provided,\nonly public information are retrieved, the other fields will contain a `null` or `empty` values.\n\nThe schema of the data above can be looked up on the onvif wsdl documents [here](https://www.onvif.org/ver10/device/wsdl/devicemgmt.wsdl)\nand [here](https://www.onvif.org/ver20/media/wsdl/media.wsdl).\n\n***Note***\n\nThis endpoint is also available using http `GET`, The request body should be sent as query params\n","operationId":"onvifDiscovery","tags":["Onvif"],"requestBody":{"content":{"application/json":{"schema":{"type":"object","properties":{"probe_timeout":{"type":"integer","description":"Maximum time to wait for a response from an onvif device to discovery requests.","minimum":1,"maximum":60,"default":2},"username":{"type":"string","description":"username to use to authorize requests to discovered devices."},"password":{"type":"string","description":"password to use to authorize requests to discovered devices."}}}}}},"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object"}}}},"400":{"$ref":"#/components/responses/BadArg"}}}},"/api/devices/{device_id}/events":{"post":{"summary":"Create a Generic Event","description":"Create a new generic event for a specific device.\n\nThe request body is stored as the event metadata.\n\n## Authorization\nSince events are pushed by third party systems, we need to authenticate these requests. For this\nwe use a `webhook` token. A webhook token has no expiry date and only authorizes this\nendpoint.\n\nThe webhook token should be sent in the `Authorization` header (recommended) or as a query param `token`.\n\n## Example\nHere's an example of using cURL to send an event to the webhook endpoint\n\n```\ncurl -X POST \\\n  \"https://my-server.com/api/devices/:device_id/events?type=my_event_type&token=:webhook_token\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"time\": \"2025-01-01T10:10:00.000000Z\",\n    \"description\": \"Example event payload\"\n  }'\n```\n","operationId":"createEvent","tags":["Event"],"parameters":[{"$ref":"#/components/parameters/device_id"}],"security":[{"bearerAuth":[]},{"queryParamAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"type":{"type":"string","description":"Event type"},"time":{"type":"string","format":"date-time","description":"Event time (defaults to current time if not provided)"}},"required":["type"]}}}},"responses":{"201":{"description":"Created","content":{}},"400":{"$ref":"#/components/responses/BadArg"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/api/devices/{device_id}/events/lpr":{"post":{"summary":"Create LPR event","description":"Create a new license plate recognition (LPR) event for a specific device.\n\nThis endpoint processes camera-specific LPR data formats and stores them in a standardized format.\n\n## Supported cameras\nMilesight LPR cameras.\n\n## Authorization\nUses the same webhook token authorization as the regular events endpoint.\n","operationId":"createLPREvent","tags":["Event"],"parameters":[{"$ref":"#/components/parameters/device_id"}],"security":[{"bearerAuth":[]},{"queryParamAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/MilesightLprEvent"},"example":{"plate":"01-D-12345","time":"2024-02-01 06:00:05.509","direction":"Approach","type":"White","resolution_width":"1920","resolution_height":"1080","coordinate_x1":"0","coordinate_y1":"100","coordinate_x2":"0","coordinate_y2":"50","plate_image":"base64encodedimagedata..."}}}},"responses":{"201":{"description":"Created","content":{}},"400":{"$ref":"#/components/responses/BadArg"},"404":{"$ref":"#/components/responses/NotFound"}}}},"/api/system/status":{"get":{"summary":"Get system status.","description":"Get information about the system status. The current exposed information are:\n\n  * CPU stats\n  * Memory\n  * Solar Charger Controller (only `Victron MPPT` for now)\n\nCheck the response schema for the detailed fields.\n","operationId":"getSystemStatus","tags":["System"],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SystemStatus"}}}},"403":{"$ref":"#/components/responses/Unauthorized"}}}},"/api/events":{"get":{"summary":"List generic events","description":"Get all generic events with pagination and filtering capabilities.\n\nThe response includes metadata about pagination and an array of events.\n","operationId":"getEvents","tags":["Event"],"parameters":[{"name":"start_date","in":"query","required":false,"description":"Filter events that occurred after this date","schema":{"type":"string","format":"date-time"},"example":"2023-01-15T10:00:01Z"},{"name":"end_date","in":"query","required":false,"description":"Filter events that occurred before this date","schema":{"type":"string","format":"date-time"},"example":"2023-01-16T10:00:01Z"},{"$ref":"#/components/parameters/filters"},{"$ref":"#/components/parameters/page"},{"$ref":"#/components/parameters/page_size"},{"$ref":"#/components/parameters/order_by"},{"$ref":"#/components/parameters/order_directions"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"meta":{"$ref":"#/components/schemas/ResultMeta"},"data":{"type":"array","items":{"$ref":"#/components/schemas/Event"}}}}}}},"400":{"$ref":"#/components/responses/BadArg"}}}},"/api/events/lpr":{"get":{"summary":"List LPR events","description":"Get all license plate recognition (LPR) events with pagination and filtering.\n\nThe response includes metadata about pagination and an array of LPR events.\n","operationId":"getLPREvents","tags":["Event"],"parameters":[{"name":"include_plate_image","in":"query","required":false,"description":"Include base64 encoded plate images in the response.\n","schema":{"type":"boolean","default":false}},{"$ref":"#/components/parameters/filters"},{"$ref":"#/components/parameters/page"},{"$ref":"#/components/parameters/page_size"},{"$ref":"#/components/parameters/order_by"},{"$ref":"#/components/parameters/order_directions"}],"responses":{"200":{"description":"Success","content":{"application/json":{"schema":{"type":"object","properties":{"meta":{"$ref":"#/components/schemas/ResultMeta"},"data":{"type":"array","items":{"$ref":"#/components/schemas/LPREvent"}}}}}}},"400":{"$ref":"#/components/responses/BadArg"}}}}},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"opaque"},"queryParamAuth":{"type":"apiKey","in":"query","name":"token"}},"schemas":{"Credentials":{"type":"object","description":"Streaming Device credentials (Only when Device type is ip)","properties":{"username":{"type":"string","description":"Username to authenticate"},"password":{"type":"string","format":"password","description":"Password to authenticate"}}},"Device":{"type":"object","properties":{"id":{"type":"string","format":"uuid","description":"Device ID"},"name":{"type":"string","description":"Device name"},"type":{"type":"string","enum":["ip","file"],"description":"Device type"},"timezone":{"type":"string"},"state":{"type":"string","enum":["recording","streaming","failed","stopped"],"description":"A device may be in one of the following states:\n\n  * `streaming` - The device is streaming media but not recording.\n  * `recording` - The device is streaming and also recording on hard drive.\n  * `failed` - The device cannot stream media for some reason.\n  * `stopped` - The device is stopped and not does nothing.\n"},"stream_config":{"$ref":"#/components/schemas/StreamConfig"},"credentials":{"$ref":"#/components/schemas/Credentials"},"settings":{"$ref":"#/components/schemas/DeviceSettings"},"storage_config":{"$ref":"#/components/schemas/DeviceStorageConfig"},"snapshot_config":{"$ref":"#components/schemas/DeviceSnapshotConfig"}}},"DeviceStorageConfig":{"type":"object","description":"Storage settings","properties":{"address":{"type":"string","description":"The mountpoint/location where to store the device data"},"record_sub_stream":{"type":"string","enum":["never","always"],"description":"When the sub stream should be recorded, it accept one of the following values:\n\n  * `never` - Do not record the sub stream.\n  * `always` - Always record the sub stream.\n"},"full_drive_threshold":{"type":"number","minimum":0,"maximum":99,"description":"The percentage when a drive should be considered full."},"full_drive_action":{"type":"string","enum":["nothing","overwrite"],"description":"The action to take when a drive is full, it can be one of the following values:\n\n  * `nothing` - Do nothing, keep recording.\n  * `overwrite` - Delete old recordings.\n"},"schedule":{"type":"object","description":"A schedule when the recordings should be stored."}},"required":["address"]},"DeviceSnapshotConfig":{"type":"object","description":"snapshot config","properties":{"enabled":{"type":"boolean","default":false,"description":"Indicates if snapshot upload to remote storage is enabled for the device or not."},"upload_interval":{"type":"number","minimum":5,"maximum":3600,"description":"The interval in seconds for snapshots upload."},"remote_storage":{"type":"string","description":"The remote storage name where the snapshots will be uploaded"},"schedule":{"type":"object","description":"Describe the time slots during which the snapshots are uploaded.\nThe keys are the week days indexes (from 1 to 7) and the values are an array of time intervals.\nIf a key is missing, then it default value will be an empty array and no snapshots will be uploaded for this day.\n","example":{"1":["08:00-20:00"],"2":["08:00-18:00"],"3":["08:00-12:00","14:00-18:00"],"4":[],"5":["00:00-23:59"],"6":["00:00-18:00"],"7":[]}}}},"DeviceSettings":{"type":"object","description":"Device settings that controls how the device behaves.","properties":{"generate_bif":{"type":"boolean","default":true,"description":"Indicates whether BIF (Base Index File) used for trick play should be generated."}},"required":["storage_address"]},"Error":{"type":"object","properties":{"code":{"type":"string","description":"A unique error code"},"description":{"type":"string","description":"The description of the error"},"details":{"type":"object","description":"Other details related to the error."}}},"HttpConfig":{"type":"object","properties":{"username":{"type":"string","description":"Remote Storage username"},"password":{"type":"string","description":"Remote Storage password"},"token":{"type":"string","description":"Remote Storage token"}}},"Event":{"type":"object","properties":{"id":{"type":"integer","description":"Event ID"},"time":{"type":"string","format":"date-time","description":"Event timestamp"},"type":{"type":"string","description":"Event type"},"metadata":{"type":"object","description":"Additional event data"},"device_id":{"type":"string","format":"uuid","description":"ID of the associated device"}}},"LPREvent":{"type":"object","properties":{"device_id":{"type":"string","format":"uuid","description":"The device id where the event belongs."},"capture_time":{"type":"string","format":"date-time","description":"Capture time of the LPR event"},"plate_number":{"type":"string","description":"Plate number of the LPR event"},"direction":{"type":"string","enum":["in","away"],"description":"Direction of the LPR Event"},"list_type":{"type":"string","enum":["white","black","other"]},"plate_image":{"type":"string","format":"binary","description":"The plate image"},"metadata":{"type":"object","properties":{"confidence":{"type":"number","description":"The confidence level of the recognized plate","minimum":0,"maximum":1},"bounding_box":{"type":"array","items":{"type":"number","minimum":0,"maximum":1},"minItems":4,"maxItems":4,"description":"The normalized coordinates of the plate."},"plate_color":{"type":"string","description":"The color of the vehicle plate."},"vehicle_type":{"type":"string","description":"The type of the vehicle"},"vehicle_color":{"type":"string","description":"The vehicle color."}}}}},"MilesightLprEvent":{"type":"object","description":"LPR event data format for Milesight cameras","properties":{"plate":{"type":"string","description":"The recognized license plate number","example":"01-D-12345"},"time":{"type":"string","description":"Time when the license plate was captured","example":"2024-02-01 06:00:05.509"},"direction":{"type":"string","description":"Direction of the vehicle","enum":["Approach","Leave"],"example":"Approach"},"type":{"type":"string","description":"List type of the plate","enum":["White","Black","Other"],"example":"White"},"resolution_width":{"type":"string","description":"Width of the captured image","example":"1920"},"resolution_height":{"type":"string","description":"Height of the captured image","example":"1080"},"coordinate_x1":{"type":"string","description":"X coordinate of the first point of the plate bounding box","example":"0"},"coordinate_y1":{"type":"string","description":"Y coordinate of the first point of the plate bounding box","example":"100"},"coordinate_x2":{"type":"string","description":"X coordinate of the second point of the plate bounding box","example":"0"},"coordinate_y2":{"type":"string","description":"Y coordinate of the second point of the plate bounding box","example":"50"},"plate_image":{"type":"string","format":"base64","description":"Base64-encoded image of the license plate"}}},"Recording":{"type":"object","properties":{"id":{"type":"integer","description":"Recording unique id"},"filename":{"type":"string","description":"The filename of the recording"},"start_date":{"type":"string","format":"date-time","description":"The start date of the recording"},"end_date":{"type":"string","format":"date-time","description":"The end date of the recording"},"device_id":{"type":"string","format":"uuid","description":"The device id where this recording belongs"}}},"RemoteStorage":{"type":"object","properties":{"id":{"type":"integer","description":"Remote storage id"},"name":{"type":"string","description":"Remote storage name"},"url":{"type":"string","description":"Remote storage url"},"type":{"type":"string","enum":["s3","http"],"description":"The type of the remote storage.."}}},"ResultMeta":{"type":"object","properties":{"current_page":{"type":"integer"},"page_size":{"type":"integer"},"total_count":{"type":"integer"},"total_pages":{"type":"integer"}}},"S3Config":{"type":"object","properties":{"bucket":{"type":"string","description":"S3 bucket name."},"region":{"type":"string","description":"Remote Storage region","default":"us-east-1"},"prefix":{"type":"string","nullable":true,"description":"Folder in the bucket under which footage exports are written, as\n`<prefix>/<camera_id>/YYYY/MM/DD/HH/MM_SS.mp4`. Folders are separated\nby `/` and made of letters, numbers, dot, dash or underscore; leading\nand trailing slashes are dropped. Exports go to the bucket root when\nempty.\n","example":"site-a/nvr-1"},"access_key_id":{"type":"string","description":"Remote Storage access_key_id."},"secret_access_key":{"type":"string","description":"Remote Storage secret_access_key."}}},"StreamConfig":{"type":"object","description":"Device stream configuration","properties":{"stream_uri":{"type":"string","format":"uri","description":"The RTSP URL where to get the video stream (Only when Device type is ip)"},"substream_uri":{"type":"string","format":"uri","description":"The RTSP URL where to get the video sub-stream (Only when Device type is ip)"},"location":{"type":"string","format":"path","description":"The Path of the file location to be used as a streaming source (Only when Device type is file)"}}},"SystemStatus":{"type":"object","description":"System status information","properties":{"version":{"type":"string","description":"`ex_nvr` version.","example":"0.16.2"},"cpu":{"type":"object","description":"cpu stats.","properties":{"load":{"type":"array","description":"CPU load information. It's a 3 items array that represents 1, 5 and 15 minutes load respectively.\n\nTo caluclate the average over all cores, just divide the value by the `num_cores` field.\n\nThe system is loaded if the average over all cores `> 1` for some time.\n","items":{"type":"number","minimum":0},"minItems":3,"maxitems":3},"num_cores":{"type":"integer","description":"The total number of cpu cores in the system.","minimum":1}}},"memory":{"type":"object","description":"System memory stats.\n\nFor more details about the memory types reported here, see [erlang docs](https://www.erlang.org/doc/apps/os_mon/memsup.html#get_system_memory_data/0).\n","properties":{"system_total_memory":{"type":"integer"},"free_memory":{"type":"integer"},"total_memory":{"type":"integer"},"buffered_memory":{"type":"integer"},"cached_memory":{"type":"integer"},"total_swap":{"type":"integer"},"free_swap":{"type":"integer"},"available_memory":{"type":"integer"}}},"devices":{"type":"array","items":{"type":"object"},"description":"Information and stats about the devices (e.g. cameras)."},"block_storage":{"type":"object","description":"Block storage information"},"solar_charger":{"$ref":"#/components/schemas/Victron"},"hostname":{"type":"string","description":"The hostname of the system"},"serial_number":{"type":"string","description":"The serial number of the system"},"device_model":{"type":"string","description":"The device model."},"serial_ports":{"type":"object","description":"The serial ports attached to the device."}}},"User":{"type":"object","properties":{"id":{"type":"string","format":"uuid","description":"user ID"},"first_name":{"type":"string","description":"User first name"},"last_name":{"type":"string","description":"User last name"},"username":{"type":"string","description":"User username"},"email":{"type":"string","description":"User email"},"role":{"type":"string","enum":["admin","user"],"description":"User's role.\n\n* `admin` - Has access to all features (Default).\n* `user` - Has only \"read\" access to devices, recordings as well as streaming features.\n  Does not have access to Onvif Discovery and users management.\n"},"language":{"type":"string","enum":["en"],"description":"User's application language.\nDefault to: en (English)\n* Only english available for now.\n"}}},"Victron":{"type":"object","description":"Data received from Victron MPPT (BlueSolar and SmartSolar) and SmartShunt via serial port.","nullable":true,"properties":{"v":{"type":"integer","description":"Main channel (or battery) voltage in mV."},"vpv":{"type":"integer","description":"Panel voltage in mV"},"ppv":{"type":"integer","description":"Panel power in W"},"i":{"type":"integer","description":"Main or channel 1 battery current in mA.\n\nPositive value means the battery is charging, a negative one means battery\nis discharging.\n"},"il":{"type":"integer","description":"Load current in mA."},"load":{"type":"string","description":"Load output status."},"relay_state":{"type":"string","description":"The relay state."},"off_reason":{"type":"integer","description":"The off reason."},"p":{"type":"integer","description":"Instantaneous power."},"battery_temp":{"type":"integer","description":"Battery temperature"},"consumed_amps":{"type":"integer","description":"Consumed amps hours in mAh"},"soc":{"type":"integer","description":"State of charge in ‰."},"ttg":{"type":"integer","description":"Time to go in minutes. -1 if not discharging."},"alarm":{"type":"string","enum":["on","off"],"description":"alarm state."},"alarm_reasons":{"type":"array","items":{"type":"string"},"description":"List of reasons for the alarm if alarm is `on`."},"h1":{"type":"integer","description":"Depth of the deepest discharge in mAh"},"h2":{"type":"integer","description":"Depth of the lasst discharge in mAh"},"h3":{"type":"integer","description":"Depth of the average discharge in mAh"},"h4":{"type":"integer","description":"Number of charge cycles"},"h5":{"type":"integer","description":"Number of full discharges"},"h6":{"type":"integer","description":"Cumulative Amps hours drawn in mAh"},"h9":{"type":"integer","description":"Number of seconds since last full charge"},"h19":{"type":"integer","description":"Yield total in 0.01 kWh."},"h20":{"type":"integer","description":"Yield today in 0.01 kWh."},"h21":{"type":"integer","description":"Maximum power today in W."},"h22":{"type":"integer","description":"Yield yesterday in 0.01 kWh."},"h23":{"type":"integer","description":"Maximum power yesterday in W."},"err":{"type":"integer","description":"The error code."},"cs":{"type":"string","enum":["off","fault","bulk","absorption","float","equalize","starting_up","auto_equalize","external_control","unknown"],"description":"The state of operation."},"fw":{"type":"string","description":"The firmware version."},"pid":{"type":"string","description":"The product id."},"serial_number":{"type":"string","description":"The serial number."}}}},"parameters":{"remote_storage_id":{"name":"remote_storage_id","description":"The id of the remote_storage","in":"path","required":true,"schema":{"type":"number"},"example":11},"device_id":{"name":"device_id","description":"The id of the device","in":"path","required":true,"schema":{"type":"string","format":"uuid"},"example":"d0d83123-b3af-48b0-b9ea-2569179a7517"},"recording_id":{"name":"recording_id","description":"The filename of the recording","in":"path","required":true,"schema":{"type":"string"},"example":"11236565645.mp4"},"stream_type":{"name":"stream","in":"query","required":false,"description":"Stream type.\n\n`auto` value means try `low` stream first if available and then `high` stream.\n","schema":{"type":"string","enum":["high","low","auto"],"default":"high"}},"filters":{"name":"filters","in":"query","required":false,"explode":true,"description":"Apply a filter.\n\nAn example:\n```\nfilters[0][field]=device_id&filters[0][value]=value1&filters[1][field]=start_date&filters[1][op]=>=&filters[1][value]=2023-11-27T10:00:00Z\n```\n","schema":{"type":"array","items":{"type":"object","properties":{"field":{"type":"string","description":"The field to filter on"},"op":{"type":"string","description":"The operator to use for comparison"},"value":{"type":"string","description":"The value of the filter"}}}}},"order_by":{"name":"order_by[]","in":"query","required":false,"explode":true,"description":"Order by a field.\n\nAn example:\n```\norder_by[]=name&order_by[]=age\n```\n","schema":{"type":"array","items":{"type":"string"}}},"order_directions":{"name":"order_directions[]","in":"query","required":false,"description":"Specify the order direction.\n\nAn example:\n```\norder_directions[]=asc&order_directions[]=desc\n```\n","schema":{"type":"array","items":{"type":"string"}}},"page":{"name":"page","in":"query","required":false,"explode":true,"description":"The requested page number","schema":{"type":"integer"}},"page_size":{"name":"page_size","in":"query","required":false,"description":"The size of the requested page.","schema":{"type":"integer"}},"user_id":{"name":"user_id","description":"The id of the user","in":"path","required":true,"schema":{"type":"string","format":"uuid"},"example":"1d7c7f47-63c1-4bef-91a6-124cbaf3ecea"}},"responses":{"BadArg":{"description":"Bad Arguments","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"NotFound":{"description":"Not Found","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}},"Unauthorized":{"description":"Unauthorized access","content":{"application/json":{"schema":{"type":"object","properties":{"message":{"type":"string"}}}}}}}},"security":[{"bearerAuth":[]}]}