You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP

hikvision-apis

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
h

hikvision-apis

HIKVISION APIs

0.1.5
latest
73

Supply Chain Security

100

Vulnerability

66

Quality

79

Maintenance

100

License

Version published
Weekly downloads
1
-66.67%
Maintainers
1
Weekly downloads
 
Created
Issues
0

HIKVISION APIs

License: GPL v3

The project contains a collection of ISAPI APIs from HIK Vision, described in https://tpp.hikvision.com/Wiki/ISAPI/, and allows the conversion of XML types to TypeScript types.

Getting Started

Create an ISAPI instance.

const instance = new ISAPI({
  host: '192.168.1.64',
  port: 80,
  username: 'admin',
  password: 'password',
});

Call api using url.

import { PTZChannelList } from '@types';

const url = '/ISAPI/PTZCtrl/channels';
instance
  .get<PTZChannelList>(url)
  .then((res: PTZChannelList) => console.log(res))
  .catch((error: AxiosError<ResponseStatus>) =>
    console.error(error.response?.data),
  );

Or call provided apis.

instance
  .getPTZCtrlChannels()
  .then((res: PTZChannelList) => console.log(res))
  .catch((error: AxiosError<ResponseStatus>) =>
    console.error(error.response?.data),
  );

The response is as follows.

{
  PTZChannelList: {
    _attributes: {
      version: '2.0',
      xmlns: 'http://www.hikvision.com/ver20/XMLSchema'
    },
    PTZChannel: {
      _attributes: [Object],
      id: 1,
      enabled: true,
      videoInputID: 1,
      controlProtocol: 'PELCO-D',
      controlAddress: [Object],
      panSupport: true,
      tiltSupport: true,
      zoomSupport: false
    }
  }
}

Get xml response by calling get with { convert: false } parameter.

const url = '/ISAPI/PTZCtrl/channels';
await instance
  .get<string>(url, { convert: false })
  .then((res: string) => console.log(res))
  .catch((error: AxiosError) => console.error(error));

XML response.

<?xml version="1.0" encoding="UTF-8"?>
<PTZChannelList  version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<PTZChannel version="2.0" xmlns="http://www.hikvision.com/ver20/XMLSchema">
<id>1</id>
<enabled>true</enabled>
<videoInputID>1</videoInputID>
<controlProtocol>PELCO-D</controlProtocol>
<controlAddress>
<enabled>true</enabled>
<Address>0</Address>
</controlAddress>
<panSupport>true</panSupport>
<tiltSupport>true</tiltSupport>
<zoomSupport>false</zoomSupport>
</PTZChannel>
</PTZChannelList >

Document

Clone the repo and run docs script.

git clone git@github.com:sakharin/hikvision-apis.git
cd hikvision-apis
npm install
npm run doc

Then open docs/index.html.

References

The project structure is modified from tomchen/example-typescript-package.

FAQs

Package last updated on 05 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts