Skip to main content

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 2.1.1

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

Source distribution (sdist)

Source distribution for hikconnect 2.1.1
File Size Uploaded
hikconnect-2.1.1.tar.gz 10.3 kB Details

Built distribution (wheel)

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

Total release size: 20.1 kB

Release files / hikconnect-2.1.1.tar.gz

Download URL hikconnect-2.1.1.tar.gz
Size 10.3 kB
Tags Source
SHA-256 checksum
How to use checksums
0042ba5d6c32c08b51ff0db3a69d697cdeec81ebfb7e81c114b10e620d9ae2cb
BLAKE2b-256 checksum
How to use checksums
e3bba5b71a75976f45cd0cbfb6b42f26b26b8211e0782b91d34b3678c593982b
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 4, 2026.

Transparency log

Release files / hikconnect-2.1.1-py3-none-any.whl

Download URL hikconnect-2.1.1-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7d1d2859df13ed153924ab04a430b69a3d7598e6ae8533783c48988c92da8ed4
BLAKE2b-256 checksum
How to use checksums
cae1b5a2382bbf7b1ed5a497d3e1a77072da59db787a4d0581a9a435ea9c663a
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 4, 2026.

Transparency log

Release history Release notifications | RSS feed

3.0.1

2 release files

3.0.0

2 release files

This release

2.1.1 This release

2 release files

2.1.0

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.3.0

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

0.7.3

2 release files

0.7.2

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

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