node-unifi
NodeJS class for querying UniFi-Controller (www.ubnt.com)
Last updated 3 months ago by jens-maus .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install node-unifi 
SYNC missed versions from official npm registry.

Logo

node-unifi

Build NPM version Downloads License Donate Known Vulnerabilities GitHub stars

NPM

Node-UniFi is a NodeJS module that allows to query/control UniFi devices via the official UniFi-Controller API. It is developed to be compatible to the latest UniFi-Controller API version starting with v4.x.x/v5.x.x.

Features

  • Supports all UniFi-Controller API features introduced with v4.x.x and v5.x.x.
  • Supports CloudKey Gen1, CloudKey Gen2, UnifiOS-based UDM-Pro Controller as well as self-hostd UniFi Controller Software.
  • Returns all data in JSON parsable strings/objects.

Requirements

  • Installed UniFi-Controller version v4 or v5, CloudKey Gen1, Gen2 or UDM-Pro.
  • Working UniFi-device environment

Installation

node-unifi can be installed using the following npm command:

npm install node-unifi

Example

node-unifi has been designed to be used quite straight forward and without introducing ackward language constructs. The following example should give a brief introduction on how to use node-unifi in your own applications:

var unifi = require('node-unifi');

var controller = new unifi.Controller("127.0.0.1", 8443);

// LOGIN
controller.login("admin", "PASSWORD", function(err) {

  if(err) {
    console.log('ERROR: ' + err);
    return;
  }

  // GET SITE STATS
  controller.getSitesStats(function(err, sites) {
    console.log('getSitesStats: ' + sites[0].name + ' : ' + sites.length);
    console.log(JSON.stringify(sites));

    // GET SITE SYSINFO
    controller.getSiteSysinfo(sites[0].name, function(err, sysinfo) {
      console.log('getSiteSysinfo: ' + sysinfo.length);
      console.log(JSON.stringify(sysinfo));

      // GET CLIENT DEVICES
      controller.getClientDevices(sites[0].name, function(err, client_data) {
        console.log('getClientDevices: ' + client_data[0].length);
        console.log(JSON.stringify(client_data));

        // GET ALL USERS EVER CONNECTED
        controller.getAllUsers(sites[0].name, function(err, users_data) {
          console.log('getAllUsers: ' + users_data[0].length);
          console.log(JSON.stringify(users_data));

          // FINALIZE, LOGOUT AND FINISH
          controller.logout();
        });
      });
    });
  });
});

Please note that with every controller.XXXXX() function a callback function have to be specified which will be called with a potential error message and the result data (second argument) as soon as the request succeeded.

References

This nodejs package/class uses functionality/Know-How gathered from different third-party projects:

Use-Cases

The following projects are known to use this nodejs class for query/control UniFi devices:

License

The MIT License (MIT)

Copyright (c) 2017-2020 Jens Maus <mail@jens-maus.de>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Current Tags

  • 1.3.6                                ...           latest (3 months ago)

16 Versions

  • 1.3.6                                ...           3 months ago
  • 1.3.5                                ...           3 months ago
  • 1.3.4                                ...           3 months ago
  • 1.3.3                                ...           4 months ago
  • 1.3.2                                ...           4 months ago
  • 1.3.1                                ...           4 months ago
  • 1.3.0                                ...           4 months ago
  • 1.2.2                                ...           3 years ago
  • 1.2.1                                ...           3 years ago
  • 1.2.0                                ...           3 years ago
  • 1.1.1                                ...           4 years ago
  • 1.1.0                                ...           4 years ago
  • 1.0.3                                ...           4 years ago
  • 1.0.2                                ...           4 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 1
Last Day 0
Last Week 0
Last Month 31
Dependencies (2)
Dev Dependencies (8)

Copyright 2014 - 2016 © taobao.org |