Skip to content

CopCart/node-hikvision-api

 
 

Repository files navigation

node-hikvision-api

GPL-3.0 npm node

A Node.js Module for communication with HikVision IP Cameras, now updated with Typescript and proper ISAPI calls.

Getting Started:

Installing:

npm i @copcart/node-hikvision-api

Importing:

import { HikVision } from '@copcart/node-hikvision-api';

Configuring:

const camera = new HikVision({
  username: 'admin',     // Required
  password: 'password',  // Required
  host: '192.168.1.64',  // Required
  debug: true,           // Optional, defaults to false
  port: 80,              // Optional, defaults to 80
  reconnectAfter: 30000, // Optional, defaults to 30000 (30s)
  protocol: 'http',      // Optional, defaults to 'http'
});

Additionally, you can run examples (available in examples/) like shown:

npm run example:basic CAMERA_IP CAMERA_PASSWORD CAMERA_USERNAME  

There are more examples available as npm scripts, so please check package.json

Status

Work in Progress

Working:

  • View/update stream channel parameters
    • Partial validation before sending XML is possible, see example 5
  • Get device status
  • Enable/disable ONVIF
  • Add/remove ONVIF users
  • Checking for day mode/night mode
  • Camera alarm handling (see below)

Encryption:

Though HikVision's ISAPI protocol supports security using URL parameters, I was unable to get it working properly. Anyone is welcome to pick up where I left off in src/lib/hikvision.encryption.ts.

The ISAPI spec includes the full steps in Chapter 3, but this is the general idea: ISAPI encryption steps ISAPI encryption steps

Without encryption one should not use this library to pass sensitive data at all even if you are using HTTPS.

Notes

There are major differences between this library and the original one

For instance, the previous version of this library had PTZ functionalities, however this is not within the scope of this library. In my own opinion, you should be using ONVIF for those functions.

Roadmap

  • Implement proper sensitive data encryption
  • Write unit tests
  • Implement NetworkInterface validation
  • Return PTZ capabilities
  • Basic error handling (right now the axios ref is thrown all the way up the stack)
  • Clean up alarm notification handling

About

Node.js Module for Hikvision IPC HTTP API

Resources

License

Stars

Watchers

Forks

Languages

  • TypeScript 81.5%
  • C# 17.3%
  • JavaScript 1.2%