Skip to main content

PyPI

Introduction

This is a python module for interacting with Hikvision IP cameras and NVRs. Most rebadged models work as well with full functionality. It provides two ways to talk to a device:

  • HikCamera - connects to a device's ISAPI event stream and tracks event/sensor state changes in real time (motion, line crossing, tamper, I/O, disk errors, etc.), with callbacks on updates. Also supports snapshots, RTSP stream URLs, motion detection toggling, and recording search/download.
  • ISAPIClient - a synchronous ISAPI client for querying and controlling a device: device info/capabilities, storage devices, streaming channels, cameras, I/O ports, event enable/disable, snapshots, RTSP URLs, holiday mode, and reboot.

Code is licensed under the MIT license.

Requirements

Optional:

  • xmltodict >= 0.13.0 - required for ISAPIClient (install with the isapi extra)
  • pyDispatcher 2.0.5 - only needed if you want HikCamera to also broadcast updates via pydispatch signals; the built-in callback mechanism (add_update_callback) works without it

Installation

pip install pyhik

To also use ISAPIClient:

pip install pyhik[isapi]

Usage - Event streaming (HikCamera)

import pyhik.hikvision as hikvision

camera = hikvision.HikCamera('http://X.X.X.X', port=80, usr='admin', pwd='1234')

# Register a callback, then start the event stream processing thread
camera.add_update_callback(lambda msg: print('Update:', msg), camera.get_id)
camera.start_stream()

print(camera.get_name, camera.current_event_states)

# ...when finished
camera.disconnect()

Callbacks

  • add_update_callback(callback, msg) - register a callback function, called with cam_id.event_type.channel whenever a tracked event changes state.

Properties

  • get_id - unique camera/NVR id
  • get_name - camera/NVR name
  • get_type - device type (CAM or NVR)
  • current_event_states - dictionary of all tracked events and their current state
  • current_motion_detection_state - current motion detection on/off state
  • stream_connected - whether the event stream is currently connected

Functions

  • start_stream() - start the event stream processing thread
  • disconnect() - close the event stream session and stop the processing thread
  • get_channels() - list available channels
  • get_motion_detection() / enable_motion_detection() / disable_motion_detection() - read/toggle motion detection
  • get_snapshot(channel=1) - fetch a JPEG snapshot for a channel
  • get_stream_url(channel=1, protocol='rtsp', stream_type=1) - build an RTSP stream URL
  • fetch_attributes(event, channel) - get the state list for a specific sensor/channel
  • get_recording_days(track_id, start_date, end_date) - list days that have recordings
  • search_recordings(track_id, start_time, end_time, max_results=100) - search for recordings in a time range
  • download_recording(playback_uri, output_stream=None, chunk_size=65536) - download a recording found via search_recordings

Usage - Device control (ISAPIClient)

from pyhik.isapi import ISAPIClient

with ISAPIClient('X.X.X.X', port=80, username='admin', password='1234') as client:
    print(client.get_device_name(), client.get_firmware_version())
    print(client.get_capabilities())

    snapshot = client.get_snapshot(channel=1)
    rtsp_url = client.get_rtsp_url(channel=1)

Functions

  • get_device_info() / get_device_serial() / get_device_name() / get_device_model() / get_device_type() / get_firmware_version() - device identity
  • get_capabilities() - returns a DeviceCapabilities summary of what the device supports
  • get_storage_devices() - list StorageDevice entries (HDD/SD status, capacity)
  • get_alarm_server_info() / configure via request() - alarm server settings
  • get_streaming_channels() - list StreamInfo for available streams
  • get_cameras() - list CameraInfo (useful on NVRs with multiple channels)
  • get_output_ports() / get_input_ports() - list I/O ports
  • get_output_state(output_id) / set_output_state(output_id, state) - read/set an output relay
  • get_holiday_mode_enabled() / set_holiday_mode_enabled(enabled) - read/set holiday mode
  • get_event_states() / set_event_enabled(...) - read/toggle event detection types
  • get_snapshot(channel=1, stream_type=1, width=None, height=None) - fetch a snapshot
  • get_rtsp_url(channel=1, stream_type=1, include_credentials=True) - build an RTSP stream URL
  • reboot() - reboot the device
  • custom_request(...) - issue an arbitrary ISAPI request for endpoints not otherwise wrapped

TODO

  • Support IR day/night status and ability to switch between day/night/auto

Metadata

Release files for pyHik 0.4.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyHik 0.4.7
File Size Uploaded
pyhik-0.4.7.tar.gz 36.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyHik 0.4.7
File Interpreter ABI Platform
pyhik-0.4.7-py3-none-any.whl Python 3 none any Details

Total release size: 63.7 kB

Release files / pyhik-0.4.7.tar.gz

Download URL pyhik-0.4.7.tar.gz
Size 36.8 kB
Tags Source
SHA-256 checksum
How to use checksums
3caf345bf0e2a2462c3645c3c290705e7af46435bdc797bdf2f208c04923a22d
BLAKE2b-256 checksum
How to use checksums
56f79bef206467177aec87f46138efb410f2ce3ac4e58aad8f911686a69545e6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.

Transparency log

Release files / pyhik-0.4.7-py3-none-any.whl

Download URL pyhik-0.4.7-py3-none-any.whl
Size 27.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4916a9e2c9628d6e816f4a7e8a50f1701aec1eb04fee8f731f30456762ab814b
BLAKE2b-256 checksum
How to use checksums
f347ea7ac4613e2fd6b302f5b03ad97fa3b224cb9d750415ca66c4497a0c785f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.

Transparency log

Release history Release notifications | RSS feed

0.4.8

2 release files

This release

0.4.7 This release

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

1 release file

0.4.2

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.4

1 release file

0.3.3

1 release file

0.3.2

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.2.9

1 release file

0.2.8

1 release file

0.2.7

1 release file

0.2.5

1 release file

0.2.4

1 release file

0.2.3

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.9

1 release file

0.1.8

1 release file

0.1.7

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

0.0.9

1 release file

0.0.8

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page