API unifi_video.api¶
-
class
unifi_video.api.UnifiVideoAPI(api_key=None, username=None, password=None, addr=u'localhost', port=7080, schema=u'http', verify_cert=True, check_ufv_version=True)[source]¶ Bases:
objectEncapsulates a single UniFi Video server.
Parameters: - api_key (str) – UniFi Video API key
- username (str) – UniFi Video account username
- password (str) – UniFi Video account pasword
- addr (str) – UniFi Video host address
- port (int) – UniFi Video host port
- schema (str) – Protocol schema to use. Valid values: http, https
- verify_cert (bool) – Whether to verify UniFi Video’s TLS cert when connecting over HTTPS
- check_ufv_version (bool) – Set to
Falseto use with untested UniFi Video versions
Note
At minimum, you have to
- provide either an API key or a username:password pair
- set the host address and port to wherever your UniFi Video is listening at
Variables: - _data (dict) – UniFi Video “bootstrap” JSON as a dict
- base_url (str) – API base URL
- api_key (str or NoneType) – API key (from input params)
- username (str or NoneType) – Username (from input params)
- password (str or NoneType) – Password (from input params)
- name (str or NoneType) – UniFi Video server name
- version (str or NoneType) – UniFi Video version
- jsession_av (str or NoneType) – UniFi Video session ID
- cameras (
UnifiVideoCollection) – Collection ofUnifiVideoCameraobjects - recordings (
UnifiVideoCollection) – Collection ofUnifiVideoRecordingobjects
-
delete(url, data=None, raw=False)[source]¶ Send DELETE request.
Thin wrapper around
post(); the same parameter/return semantics apply here.
-
get(url, raw=False)[source]¶ Send GET request.
Parameters: - url (str) – API endpoint (relative to the API base URL)
- raw (str or bool) – Set str filename if you want to save the
response to a file. Set to
Trueif you want the to return raw response data.
Returns: Response JSON (as dict) when Content-Type response header is application/json
Trueifrawis str (filename) and a file was successfully written toRaw response body (as bytes) if the raw input param is of type bool
Falseon HTTP 4xx - 5xxReturn type: NoneType, bool, dict, bytes
-
get_camera(search_term)[source]¶ Get a camera whose
name,_id, oroverlay_textmatches search_term.Returns: UnifiVideoCameraor NoneType depending on whether or not search_term was matched to a camera.
-
post(url, data=None, raw=False, _method=None)[source]¶ Send POST request.
Parameters: - url (str) – API endpoint (relative to the API base URL)
- data (dict or NoneType) – Request body
- raw (str or bool) – Filename (str) if you want the response
saved to a file,
True(bool) if you want the response body as return value
Returns: See
get().