artemis-http-client

artemis-http-client node.js SDK

Usage no npm install needed!

<script type="module">
  import artemisHttpClient from 'https://cdn.skypack.dev/artemis-http-client';
</script>

README

artemis-http-client

open8200 Artemis Http Client Nodejs SDK

视频能力开放平台

Installation

$ npm install artemis-http-client

Usage

Example:

const co = require('co');
const {Client}  = require('artemis-http-client');

//new Client(appKey, appSecret)
const client = new Client('23967750', 'BZcz3VlqL1DVhWeF1boE');

//GET
co(function* () {
  var url = 'https://open8200.hikvision.com/artemis/api/artemis/v1/minus';

  var result = yield client.get(url, {
    query: {
      'a': 1,
      'b': 1
    },
    headers: {
      accept: 'application/json',
      'content-type':'text/plain;charset=UTF-8'
    }
  });

  console.log(JSON.stringify(result));

}).catch((error)=>{

  //请求错误信息
  console.log(JSON.stringify(error.message));

});

//POST
co(function* () {
  var url = 'https://open8200.hikvision.com/artemis/api/artemis/v1/plus';

  var result = yield client.post(url, {
    headers: {
      'content-type': "application/x-www-form-urlencoded;charset=UTF-8"
    },
    data: {
      'a': 1,
      'b': 1
    }
  });

  console.log(JSON.stringify(result));

}).catch((error)=>{

  //请求错误信息
  console.log(JSON.stringify(error.message));

});

License

(The MIT License)