Usage
from hikconnect.api import HikConnect
async with HikConnect() as api:
await api.login("foo", "bar")
devices = [device async for device in api.get_devices()]
print(devices)
# [{
# 'id': 'DS-XXXXXX-YYYYYYYYYYYYYYYYYYYYYYYYY',
# 'name': 'DS-XXXXXX-Y(ZZZZZZZZZ)',
# 'serial': 'ZZZZZZZZZ',
# 'type': 'DS-XXXXXX-Y',
# 'version': 'V1.2.3 build 123456',
# 'locks': {1: 2, 2: 0, 3: 1}
# }]
# locks data means (guessing): <channel number>: <number of locks connected>
my_device_serial = devices[0]["serial"]
cameras = [camera async for camera in api.get_cameras(my_device_serial)]
print(cameras)
# [
# {'id': '4203fd7c5f89ce96f8ff0adfdbe8b731', 'name': 'foo', 'channel_number': 1, 'signal_status': 1, 'is_shown': 0},
# {'id': 'cd72bc923956952194468738123b7a5e', 'name': 'bar', 'channel_number': 2, 'signal_status': 1, 'is_shown': 1},
# {'id': 'd2a2057d853438d9a5b4954baec136e3', 'name': 'baz', 'channel_number': 3, 'signal_status': 0, 'is_shown': 0}
# ]
call_status = await api.get_call_status(my_device_serial)
print(call_status)
# {
# 'status': 'idle',
# 'info': {
# 'building_number': 0,
# 'floor_number': 0,
# 'zone_number': 0,
# 'unit_number': 0,
# 'device_number': 0,
# 'device_type': 0,
# 'lock_number': 0
# }
# }
# can be "idle" / "ringing" / "call in progress" - see hikconnect/api.py:45
# Unlock device
await api.unlock(my_device_serial, 1)
# Cancel call for device
await api.cancel_call(my_device_serial)
# call this periodically at least once per 30 mins!
if api.is_refresh_login_needed():
await api.refresh_login()
# ---- Area (group) management ----------------------------------------
# List all areas on a device
areas = [area async for area in api.get_areas(my_device_serial)]
print(areas)
# [
# {
# 'group_id': 110548,
# 'device_serial': 'ZZZZZZZZZ',
# 'group_name': 'Entrance',
# 'group_type': 2,
# 'mode': 1, # 0=disarmed, 1=armed, 2=armed-silent
# 'create_time': 1737221666000,
# 'modify_time': 1737221666000,
# },
# ...
# ]
my_group_id = areas[0]["group_id"]
# Get cameras (resources) assigned to an area
members = await api.get_area(my_device_serial, my_group_id)
print(members)
# [
# {'group_id': 110548, 'device_serial': 'ZZZZZZZZZ', 'member_id': 'abc123...'},
# ...
# ]
# member_id corresponds to camera id returned by get_cameras()
# Create a new area with specific cameras
cameras = [camera async for camera in api.get_cameras(my_device_serial)]
camera_ids = [c["id"] for c in cameras[:2]] # first two cameras
result = await api.create_area(my_device_serial, "Front Gate", camera_ids)
new_group_id = result["group_id"]
# Update an existing area (rename and/or change cameras)
await api.update_area(my_device_serial, my_group_id, "New Name", camera_ids)
# Arm / disarm an area
await api.arm_area(my_device_serial, my_group_id) # mode=1
await api.arm_area_silent(my_device_serial, my_group_id) # mode=2 (no beep)
await api.disarm_area(my_device_serial, my_group_id) # mode=0
# Delete an area
await api.delete_area(my_device_serial, my_group_id)
If you are new to async Python, you simply need to wrap your code in a construction like this:
import asyncio
async def main():
# put the original code containing `async` keywords here
asyncio.run(main())
More info in the async docs.
Metadata
Release files for hikconnect 3.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| hikconnect-3.0.1.tar.gz | 11.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hikconnect-3.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.7 kB
Release files / hikconnect-3.0.1.tar.gz
| Download URL | hikconnect-3.0.1.tar.gz |
|---|---|
| Size | 11.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
727b087c105fc0139ae235703dc013103f71e87aca895b1630967adb24900c03
|
|
BLAKE2b-256 checksum How to use checksums |
df5e82a360e877653f709a0a84d6aadd852885bd6a29cb2f3fd177198ffe8d58
|
| 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 16, 2026.
Transparency logRelease files / hikconnect-3.0.1-py3-none-any.whl
| Download URL | hikconnect-3.0.1-py3-none-any.whl |
|---|---|
| Size | 10.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0af24e358d3a381f2cf35e90c026cd57a0c111323299d0ad8cadeb197400b049
|
|
BLAKE2b-256 checksum How to use checksums |
5f9a095a2e8d9fea279f54b7c1f8fe6773b529402eb98a7712d1314397d8ac91
|
| 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 16, 2026.
Transparency log