Package: unifi-video
unifi-video-apiPython API for interfacing with UniFi Video.Supported UniFi Video versions: v3.9.12 to v3.10.13Supported Ubiquiti camera models: UVC, UVC G3, UVC G3 Dome, UVC Dome, UVC Pro, UVC G3 Pro,
UVC G3 Flex, UVC Micro, UVC G3 Micro, airCam, airCam Dome, and airCam Mini, UVC G4 Bullet, UVC G4 Pro.FeaturesFor a single UniFi Video server:Support both username/password and API key authsProvide GET, POST, PUT, and DELETE methodsHandle session tracking and login when necessaryProvide iterable collections for cameras and recordings that the UniFi Video server
is aware ofPer camera:Set or show picture settings: brightness, contrast, saturation, hue, denoise,
sharpness, dynamic rangeSet or show IR led stateSet or show on-display textSet or show timestamp stateSet or show watermark/logo stateSet recording mode to fulltime, motion, or disabledSet recording pre/post paddingTake and download pictures (snapshots)Download camera footage between arbitrary start and end timesPer recording:DeleteDownloadSnapshot (thumbnail) downloadInstallationEither grab it from PyPIpip install unifi-videoor download a release and manually placeunifi_videoin your project
directory, or any path in$PYTHONPATH.You shouldn't need any external libraries, unless you want to run the tests or
build the docs (seerequirements_dev.txt).unifi-video-apidoes use thesixlibrary but
will fallback to using the includedsixshould it fail to importsixfrom
system level packages.Both python 2.7+ and python3 are supported.UsageSee thedocsfor an API reference.fromunifi_videoimportUnifiVideoAPI# Default kwargs: addr = 'localhost', port = 7080, schema = httpuva=UnifiVideoAPI(username='username',password='password',addr='10.3.2.1')# Use API key (can be set per user in Unifi NVR user settings)uva=UnifiVideoAPI(api_key='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',addr='10.3.2.1')# Skip version checkinguva=UnifiVideoAPI(api_key='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',addr='10.3.2.1',check_ufv_version=False)# Use HTTPS and skip cert verificationuva=UnifiVideoAPI(api_key='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',addr='10.3.2.1',port=7443,schema='https',verify_cert=False)# Save snapshot from camera whose id, name or onscreen display text# is "Garage"uva.get_camera('Garage').snapshot('some/path/snapshot.jpg')# List all cameras UniFi Video is aware offorcamerainuva.cameras:print(camera)# Save snapshot from every currently online camera managed by the UniFi Video# instance. Default filepath: # ./snapshot_{camera ID}_{timestamp}.jpgforcamerainuva.active_cameras:camera.snapshot()# List all cameras managed by the UniFi Video instance, online or notforcamerainuva.managed_cameras:camera.snapshot()# Get footage from camera "Garage" for specific timespan.# (The resulting file will be 0 bytes when no footage is found.)uva.get_camera('Garage').recording_between('2018-12-01 00:00:00','2018-12-01 00:05:00')# Specify filenameuva.get_camera('Garage').recording_between('2018-12-01 00:00:00','2018-12-01 00:05:00','first_mins_of_dec.mp4')# Change onscreen display textuva.get_camera('Garage').set_onscreen_text('Home garage')# Set IR leds to auto modeuva.get_camera('Garage').ir_leds('auto')# Turn off IR leds (manual mode implied)uva.get_camera('Garage').ir_leds('off')# Turn on IR leds (manual mode implied)uva.get_camera('Garage').ir_leds('on')# Set camera to record at all times and to pre capture 5 secsuva.get_camera('Garage').set_recording_settings('fulltime',pre_padding_secs=5)# Set camera to record motion events onlyuva.get_camera('Garage').set_recording_settings('motion')# Disable recording altogetheruva.get_camera('Garage').set_recording_settings('disable')# List recordings whose details were fetched during initializationforrecinuva.recordings:print(rec)# Download recording, write to local file recording01.mp4uva.recordings['xxxxxxxxxxxxxxxxxxxx'].download('recording01.mp4')WarningThis software has been tested against a limited set of API versions and hardware.
While unlikely, should any of the POST payloads result in software or
hardware failure, the maintainer of this package is not liable.Proceed at your own risk.