HikCentral OpenAPI Client
A Python async client library for interacting with the HikCentral OpenAPI.
This package provides typed models and helper methods for common resource and ACS workflows, including:
- Version discovery and client initialization
- Organization management
- Access level retrieval and assignment
- Person lifecycle management (including face updates)
Installation
Install with uv:
uv pip install hikcentral-openapi
Or with pip:
pip install hikcentral-openapi
Quick Start
Initialize the Client
from hikcentral_openapi import Client
client = Client(
user_key="your-user-key",
user_secret="your-user-secret",
host="localhost",
port=443,
)
await client.initialize()
print(client.version)
Use a Custom httpx.AsyncClient
import httpx
from hikcentral_openapi import Client
httpx_client = httpx.AsyncClient(verify=False)
client = Client(
user_key="your-user-key",
user_secret="your-user-secret",
httpx_client=httpx_client,
)
Usage Examples
Organizations
# Get all organizations
orgs = await client.get_organization()
# Filter organizations by name
filtered_orgs = await client.get_organization(name="Head Office")
# Get the root organization
root = await client.get_root_organization()
# Add organization under root automatically
new_org = await client.add_organization(name="Engineering")
# Add organization under explicit parent
child_org = await client.add_organization(
name="R&D",
parent_id=new_org.org_id,
)
# Update organization
child_org.org_name = "Research and Development"
await client.update_organization(child_org)
# Delete organization
await client.delete_organization(org_id=child_org.org_id)
Access Levels
# Retrieve all access levels
access_levels = await client.get_access_level()
# Assign one access level to one or more persons
level = access_levels[0]
await client.assign_access_level(
access_level=level,
person_id=["person-id-1", "person-id-2"],
)
# Remove assignment
await client.unassign_access_level(
access_level=level,
person_id=["person-id-2"],
)
Persons
from datetime import datetime, timezone
from hikcentral_openapi.models import Card, Person
# Get person by ID
person = await client.get_person(person_id="person-id-1")
# Search persons by name
persons_by_name = await client.get_person(name="John")
# Search persons by card number
persons_by_card = await client.get_person(card_no="1234567890")
# Add new person
new_person = Person(
person_code="EMP-0001",
person_name="John Doe",
org_index_code="org-index-code",
phone_no="+1-555-1000",
email="john.doe@example.com",
cards=[Card(card_no="1234567890")],
begin_time=datetime.now(timezone.utc),
)
new_person_id = await client.add_person(new_person)
# Update person
new_person.person_id = new_person_id
new_person.person_name = "John A. Doe"
await client.update_person(new_person)
# Update person face (face_data is expected as base64 string)
await client.update_person_face(
person_id=new_person_id,
face_data="base64-encoded-face-image",
)
# Delete person
await client.delete_person(person_id=new_person_id)
Data Models
Main models are available in hikcentral_openapi.models:
OrganizationAccessLevelPersonCardFaceCustomField
Error Handling
The library raises typed exceptions from hikcentral_openapi.exceptions:
HikApiError: Base exceptionConnectError: Transport-level connection errorsUnauthorizedError: Authentication/authorization failuresRequestError: API request or validation errors returned by the server
from hikcentral_openapi import Client, HikApiError
try:
await client.initialize()
except HikApiError as err:
print(f"HikCentral API error: {err}")
API Reference
- Client implementation:
src/hikcentral_openapi/client.py - Models:
src/hikcentral_openapi/models.py - Exceptions:
src/hikcentral_openapi/exceptions.py
Metadata
Release files for hikcentral-openapi 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hikcentral_openapi-0.1.2.tar.gz | 6.7 kB | Without provenance | Details for hikcentral_openapi-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hikcentral_openapi-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for hikcentral_openapi-0.1.2-py3-none-any.whl |
Total release size: 14.5 kB
Release files / hikcentral_openapi-0.1.2.tar.gz
| Download URL | hikcentral_openapi-0.1.2.tar.gz |
|---|---|
| Size | 6.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
feffc8207fadd40aa6fa27239e680309c1ebcf127a177366494a5cb9ed80bdc2
|
|
BLAKE2b-256 checksum How to use checksums |
ff56298d627de94d3de095ea88374a809d3ed5612532fa2398fd444489fd23ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / hikcentral_openapi-0.1.2-py3-none-any.whl
| Download URL | hikcentral_openapi-0.1.2-py3-none-any.whl |
|---|---|
| Size | 7.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3ef033386aaff492ea212b11d8a81df6854cb1dc5ac8b0371e8e1893cfb1b05a
|
|
BLAKE2b-256 checksum How to use checksums |
ca9c46210f10badf45e55afba0c06edeb108cdd337693bbd6bd55f78e283d134
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for hikcentral-openapi 0.1.2
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.