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 3.0.0

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 3.0.0
File Size Uploaded
hikconnect-3.0.0.tar.gz 10.8 kB Details

Built distribution (wheel)

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

Total release size: 21.1 kB

Release files / hikconnect-3.0.0.tar.gz

Download URL hikconnect-3.0.0.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ec97bf76f44ad65467bb0097ffbb917718240eeabb2e88f6956b9ad3a84d6ee4
BLAKE2b-256 checksum
How to use checksums
287756c30c455ee6e753aa59cb1f16ed431247f51788c915415e0a0535983ac1
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

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

Download URL hikconnect-3.0.0-py3-none-any.whl
Size 10.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ebeb9a64d69be1431d111a28890292c1fd39acd522847b74be7c429102a88e77
BLAKE2b-256 checksum
How to use checksums
cd6c59bd49e5ae82fc1d8976f148729f192400d921664d1be67b303d349176e1
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

Release history Release notifications | RSS feed

3.0.1

2 release files

This release

3.0.0 This release

2 release files

2.1.1

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