Skip to main content

The client for HIKVISION cameras, DVR

Project description


# Python Library for Hikvision Cameras

Simple and easy to use library for working with video equipment from Hikvision.

## Install

pip install hikvisionapi

## Examples

There are two formats for receiving a response:

from hikvisionapi import Client

cam = Client('', 'admin', 'admin')

# Dict response (default)
response = cam.System.deviceInfo(method='get')

response == {
u'DeviceInfo': {
u'@version': u'2.0',

# xml text response
response = cam.System.deviceInfo(method='get', present='text')

response == '''<?xml version="1.0" encoding="UTF-8" ?>
<DeviceInfo version="1.0" xmlns="">


# to get the channel info
motion_detection_info = cam.System.Video.inputs.channels[1].motionDetection(method='get')

# to send data to device:
xml = cam.System.deviceInfo(method='get', present='text')
cam.System.deviceInfo(method='put', data=xml)

# to get events (motion, etc..)
# Increase timeout if you want to wait for the event to be received
cam = Client('', 'admin', 'Password', timeout=30)
cam.count_events = 2 # The number of events we want to retrieve (default = 1)
response = cam.Event.notification.alertStream(method='get', type='stream')

response == [{
u'@version': u'2.0',
u'@xmlns': u'',
u'activePostCount': u'0',
u'channelID': u'1',
u'dateTime': u'2018-03-21T15:49:02+08:00',
u'eventDescription': u'videoloss alarm',
u'eventState': u'inactive',
u'eventType': u'videoloss'

# Alternative solution to get events
cam = Client('', 'admin', 'Password', timeout=1)
while True:
response = cam.Event.notification.alertStream(method='get', type='stream')
if response:
print response
except Exception:

# to get opaque data type and write to file
response = cam.System.configurationData(method='get', type='opaque_data')
with open('my_file', 'wb') as f:
for chunk in response.iter_content(chunk_size=1024):
if chunk:

# Get and save picture from camera
response = client.Streaming.channels[102].picture(method='get', type='opaque_data')
with open('screen.jpg', 'wb') as f:
for chunk in response.iter_content(chunk_size=1024):
if chunk:

## How to run the tests

pipenv install --dev
pipenv run pytest
pipenv run pytest --cov-report html --cov hikvisionapi # to get coverage report in ./htmlcov/

# or you can get into the virtual env with:
pipenv shell

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for hikvisionapi, version 0.2.1
Filename, size File type Python version Upload date Hashes
Filename, size hikvisionapi-0.2.1.tar.gz (5.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page