Hik.Api 2.0.0

dotnet add package Hik.Api --version 2.0.0
NuGet\Install-Package Hik.Api -Version 2.0.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="Hik.Api" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Hik.Api --version 2.0.0
#r "nuget: Hik.Api, 2.0.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.
// Install Hik.Api as a Cake Addin
#addin nuget:?package=Hik.Api&version=2.0.0

// Install Hik.Api as a Cake Tool
#tool nuget:?package=Hik.Api&version=2.0.0

Hik.Api

  • Available as nuget

  • dotnet add package Hik.Api

  • NuGet Downloads

  • Wrapper over Hikvision SDK version 5.3.6.30 x64. It allows login, fetch files list (videos and photos), download files, get config list and more.

  • Or just run console app sample

Initialization (static)

HikApi.Initialize();

Login (static). Returns HikApi

var hikApi = HikApi.Login("192.168.1.64", 8000, "admin", "password");

Logout

hikApi.Logout();

Cleanup (static)

HikApi.Cleanup();

Print list of IP channels for NVR (IP Camera use session.Device.DefaultIpChannel)

foreach (var channel in hikApi.IpChannels)
{
    Console.WriteLine($"{channel.Name} {channel.ChannelNumber}; IsOnline : {channel.IsOnline};");
}

Get SD Card info, capacity, free space, status etc. Returns HdInfo

var info = hikApi.ConfigService.GetHddStatus();
Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(info));

Get device config. Returns DeviceConfig

var device = hikApi.ConfigService.GetDeviceConfig();
Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(config));

Get network config. Returns NetworkConfig

var network = hikApi.ConfigService.GetNetworkConfig();
Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(network));

Get device current time

var cameraTime = hikApi.ConfigService.GetTime();
Console.WriteLine($"Camera time :{cameraTime}");

Set device time

var currentTime = DateTime.Now;
hikApi.ConfigService.SetTime(currentTime);

Photo service

Get photos list from IP Camera (default IP channel). Returns IReadOnlyCollection<HikRemoteFile>

//Get photos files for last 24 hours
DateTime fromPeriod = DateTime.Now.AddHours(-24);
DateTime toPeriod = DateTime.Now;
var photos = await hikApi.PhotoService.FindFilesAsync(fromPeriod, toPeriod);

Get photos list from specific IP channel.

int channel = 2;
var photos = await hikApi.PhotoService.FindFilesAsync(fromPeriod, toPeriod, channel);

Download photos

foreach (var photo in photos)
{
    hikApi.PhotoService.DownloadFile(
        photo.Name,
        photo.Size,
        photo.ToPhotoFileNameString());
}

or

hikApi.PhotoService.DownloadFile(photo, photo.ToPhotoFileNameString());

Video service

Get videos list from IP Camera (default IP channel). Returns IReadOnlyCollection<HikRemoteFile>

var videos = await hikApi.VideoService.FindFilesAsync(fromPeriod, toPeriod);

Get videos list from IP Camera (specific IP channel)

int channel = 2;
var videos = await hikApi.VideoService.FindFilesAsync(fromPeriod, toPeriod, channel);

Download video

foreach (var video in videos)
{
    Console.WriteLine($"Downloading {video.ToVideoFileNameString()}");
    var downloadId = hikApi.VideoService.StartDownloadFile(
        video.Name,
        video.ToVideoFileNameString());
    do
    {
        await Task.Delay(5000); // check progress every 5 sec
        int progress = hikApi.VideoService.GetDownloadPosition(downloadId);
        if (progress == 100)
        {
            hikApi.VideoService.StopDownloadFile(downloadId);
            break;
        }
        else if (progress < 0 || progress > 100)
        {
            throw new Exception($"Get progress failed, value = {downloadProgress}");
        }
    }
    while (true);
}

Playback service

Start live preview without callback

int channel = 2;
var playbackId = hikApi.PlaybackService.StartPlayBack(channel);

or start live view to WinForm PictureBox

int channel = 2;
System.Windows.Forms.PictureBox pctBox = new System.Windows.Forms.PictureBox();
var playbackId = hikApi.PlaybackService.StartPlayBack(channel, pctBox.Handle);

Start recording live stream to filePath in .mp4 format (need start playback first)

int channel = 2;
hikApi.PlaybackService.StartRecording(
    playbackId,
    "filePath.mp4",
    channel);

Stop recording live stream to filePath

hikApi.PlaybackService.StopRecording(playbackId);

Stop real play

hikApi.PlaybackService.StopPlayBack(playbackId);
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

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
2.0.0 358 1/11/2024
1.0.14 163 9/19/2023
1.0.13.1 573 6/22/2022
1.0.12 354 12/3/2021

Added ConfigService, remove Session class, hide UserId parameter