Zyga.HikIsapiClient 0.1.0

dotnet add package Zyga.HikIsapiClient --version 0.1.0
                    
NuGet\Install-Package Zyga.HikIsapiClient -Version 0.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Zyga.HikIsapiClient" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Zyga.HikIsapiClient" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Zyga.HikIsapiClient" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Zyga.HikIsapiClient --version 0.1.0
                    
#r "nuget: Zyga.HikIsapiClient, 0.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Zyga.HikIsapiClient@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Zyga.HikIsapiClient&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Zyga.HikIsapiClient&version=0.1.0
                    
Install as a Cake Tool

Zyga.HikIsapiClient

CI NuGet Downloads codecov License: MIT

A .NET client library for interacting with Hikvision devices using the ISAPI protocol, with integrated Serilog logging via Zyga.SeriRestClient.

Features

  • 🔐 Session Management - Automatic login/logout handling with session keep-alive
  • 🚪 Door Control - Remote door control operations
  • 📝 Logging - Request/response logging via Zyga.SeriRestClient's Serilog integration
  • 🔄 State Management - Smart session state handling with EnsureLoggedIn()
  • 🔌 Dependency Injection - First-class support for Microsoft.Extensions.DependencyInjection
  • 🎯 Keyed Services - Support for multiple Hikvision device instances
  • ⚙️ Configuration - Easy configuration through IConfiguration

Install

dotnet add package Zyga.HikIsapiClient

Targets .NET 8, .NET 9 and .NET 10.

Usage

Basic Setup

Configure your Hikvision device in appsettings.json:

{
  "HikDevice": {
    "Name": "Main Entrance",
    "Address": "http://192.168.1.100",
    "User": "admin",
    "Password": "your-password",
    "MaxTimeout": 5000
  }
}

Register in your Program.cs or Startup.cs:

using Zyga.HikIsapiClient.ExtensionMethods;

Host.CreateDefaultBuilder(args)
    .AddHikIsapi("HikDevice")
    .Build()
    .Run();

Using the Client

public class MyService
{
    private readonly IIsapi _isapi;

    public MyService(IIsapi isapi)
    {
        _isapi = isapi;
    }

    public void OpenDoor()
    {
        // Check if device is available
        if (!_isapi.IsAvailable())
        {
            throw new Exception("Device is not available");
        }

        // Login and open door #1
        _isapi.Login()
              .DoorOpen(1)
              .LogOut();
    }

    public void MaintainSession()
    {
        // Ensure logged in (will login only if needed)
        var authenticated = _isapi.EnsureLoggedIn();

        // Send heartbeat to keep session alive
        authenticated.SessionHeartBeat();

        // Check heartbeat count
        Console.WriteLine($"Heartbeats sent: {authenticated.HeartBeatCount}");
    }
}

Multiple Devices (Keyed Services)

Register multiple Hikvision devices:

services
    .AddKeyedHikIsapi("entrance", (sp, key) =>
        sp.GetRequiredService<IConfiguration>()
          .GetSection("Devices:Entrance")
          .Get<IsapiConfig>())
    .AddKeyedHikIsapi("parking", (sp, key) =>
        sp.GetRequiredService<IConfiguration>()
          .GetSection("Devices:Parking")
          .Get<IsapiConfig>());

Use keyed services:

public class SecurityService
{
    private readonly IIsapi _entranceDevice;
    private readonly IIsapi _parkingDevice;

    public SecurityService(
        [FromKeyedServices("entrance")] IIsapi entranceDevice,
        [FromKeyedServices("parking")] IIsapi parkingDevice)
    {
        _entranceDevice = entranceDevice;
        _parkingDevice = parkingDevice;
    }
}

API Reference

IIsapi Interface

Method Description
Login() Authenticate and establish a session with the device
EnsureLoggedIn() Login only if not already authenticated
IsAvailable() Check if the device is reachable

IIsapiAuthenticated Interface

Method Description
DoorOpen(int doorNo) Trigger door opening for specified door number
SessionHeartBeat() Send keep-alive signal to maintain session
LogOut() End the current session
HeartBeatCount Get the number of heartbeats sent in current session

IIsapiConfig Interface

Property Description
Name Friendly name for the device
Address Base URL of the Hikvision device (e.g., http://192.168.1.100)
User Username for authentication
Password Password for authentication
MaxTimeout Maximum request timeout in milliseconds (default: 5000)

Sample

A runnable console sample lives in samples/HikIsapiClient.Sample — point its appsettings.json at your own device before running it.

Requirements

  • .NET 8, .NET 9, or .NET 10
  • RestSharp 114.0.0+
  • Serilog 4.4.0+
  • Zyga.SeriRestClient 0.1.1+

Contributing

Issues and pull requests are welcome. See CONTRIBUTING.md.

License

MIT

Version

This package uses MinVer for semantic versioning, derived from v-prefixed git tags (e.g. v1.2.3). There is no <Version> element anywhere in the source — maintainers cut a release by pushing a tag.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0 41 10/16/2026