DEV Community

Dmitry Gordin
Dmitry Gordin

Posted on

53 2

Hikvision camera configuration via ISAPI

Hikvision company makes good cameras and terrible documentation for their software.
If you've ended up here, chances are you've tried digging through their "isapi.pdf" file and didn't find much help there.

First, I'd suggest you get your camera set up via the web interface. Next, grab a reference template of the settings in XML format. Do it by opening in you browser:

In case you have different models of cameras, probably you need to get this templates from all of them, compare, and find common basis.

To deploy this config to camera simply PUT this xml text to camera by the same url!

Sample python code:

import requests
from requests.auth import HTTPDigestAuth

username, password = ('admin', 'camera_password')
stream_xml = """
<StreamingChannel version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
    <id>1</id>
blah blah blah
"""
url = "http://192.168.1.64/ISAPI/Streaming/channels/1"
response = requests.put(url, data=stream_xml, auth=HTTPDigestAuth(username, password))
print(response.text)
assert response.status_code == 200

image_xml = """
<ImageChannel xmlns="http://www.hikvision.com/ver20/XMLSchema" version="2.0">
    <id>1</id>
    <enabled>true</enabled>
    <videoInputID>1</videoInputID>
"""
url = "http://192.168.1.64/ISAPI/Image/channels/1"
response = requests.put(url, data=image_xml, auth=HTTPDigestAuth(username, password))
print(response.text)
assert response.status_code == 200
Enter fullscreen mode Exit fullscreen mode

You should get response like:

<?xml version="1.0" encoding="UTF-8"?>
<ResponseStatus version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<requestURL></requestURL>
<statusCode>1</statusCode>
<statusString>OK</statusString>
<subStatusCode>ok</subStatusCode>
</ResponseStatus>
Enter fullscreen mode Exit fullscreen mode

In more complex case, when you need different configs for each camera model, use: http://192.168.1.64/ISAPI/System/deviceInfo to find out camera model.

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (3)

Collapse
 
cibermesias profile image
Allfarid Morales García

Every URI I've tested so far returns this exact XML:
<ResponseStatus xmlns="http://www.hikvision.com/ver10/XMLSchema" version="1.0">
<script/>
<requestURL/>
<statusCode>4</statusCode>
<statusString>Invalid Operation</statusString>
<subStatusCode>notSupport</subStatusCode>
<errorCode>1073741825</errorCode>
<errorMsg>notSupport</errorMsg>
</ResponseStatus>

What am I doing wrong?

Collapse
 
eduardo_guimaraes_e4c1fc3 profile image
Eduardo Guimaraes

Please I need a help to zoom in

Collapse
 
gordinmitya profile image
Dmitry Gordin

me too

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay