Hik.Api
1.0.14
See the version list below for details.
dotnet add package Hik.Api --version 1.0.14
NuGet\Install-Package Hik.Api -Version 1.0.14
<PackageReference Include="Hik.Api" Version="1.0.14" />
paket add Hik.Api --version 1.0.14
#r "nuget: Hik.Api, 1.0.14"
// Install Hik.Api as a Cake Addin #addin nuget:?package=Hik.Api&version=1.0.14 // Install Hik.Api as a Cake Tool #tool nuget:?package=Hik.Api&version=1.0.14
Hik.Api
Avaliable as nuget
dotnet add package Hik.Api --version 1.0.14
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
IHikApi hikApi = new HikApi();
hikApi.Initialize();
hikApi.SetupLogs(3, "C:\\sdkLogsPath", false);
hikApi.SetConnectTime(2000, 1);
hikApi.SetReconnect(10000, 1);
Login. Returns Session
var session = hikApi.Login("192.168.1.64", 8000, "admin", "pass");
Warning: Almost every method requires session.UserId. I'm going to remove this parameter in future versions of package.
Logout
hikApi.Logout(session.UserId);
hikApi.Cleanup();
Print list of IP channels for NVR (IP Camera use session.Device.DefaultIpChannel)
foreach (var channel in session.Device.IpChannels)
{
Console.WriteLine($"{channel.Name} {channel.ChannelNumber}; IsOnline : {channel.IsOnline};");
}
Get SD Card info, capaity, free space, status etc. Returns HdInfo
var info = hikApi.GetHddStatus(session.UserId);
Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(info));
Get device config. Returns DeviceConfig
var config = hikApi.GetDeviceConfig(session.UserId);
Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(config));
Get network config. Returns NetworkConfig
var network = hikApi.GetNetworkConfig(session.UserId);
Console.WriteLine(Newtonsoft.Json.JsonConvert.SerializeObject(network));
Get device current time
var cameraTime = hikApi.GetTime(session.UserId);
Console.WriteLine($"Camera time :{cameraTime}");
Set device time
var currentTime = DateTime.Now;
hikApi.SetTime(currentTime, session.UserId);
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, session);
Get photos list from specific IP channel.
int channel = 2;
var photos = await hikApi.PhotoService.FindFilesAsync(fromPeriod, toPeriod, session, channel);
Download photos
foreach (var photo in photos)
{
hikApi.PhotoService.DownloadFile(
session.UserId,
photo.Name,
photo.Size,
photo.ToPhotoFileNameString());
}
or
hikApi.PhotoService.DownloadFile(session.UserId, 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, session);
Get videos list from IP Camera (specific IP channel)
int channel = 2;
var videos = await hikApi.VideoService.FindFilesAsync(fromPeriod, toPeriod, session, channel);
Download video
foreach (var video in videos)
{
Console.WriteLine($"Downloading {video.ToVideoFileNameString()}");
var downloadId = hikApi.VideoService.StartDownloadFile(
session.UserId,
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(session.UserId, 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(session.UserId, 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",
session.UserId,
channel);
Stop recording live stream to filePath
hikApi.PlaybackService.StopRecording(playbackId);
Stop real play
hikApi.PlaybackService.StopPlayBack(playbackId);
Product | Versions 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. |
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.
Summary of changes made in this release of the package.