npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-unmsapi

v0.0.2

Published

Provides API to manage Ubiquiti UNMS Controller

Downloads

6

Readme

node-unmsapi

Ubiquiti UNMS API ported to Node.JS

Major features

** Under development

Installation

To install run:

npm install node-unmsapi --save

Usage

All the API are Promises

Direct access to UNMS Controller

If you have a direct access to Ubiquiti UNMS Controller, you could use the following API:

let unms = require('node-unmsapi');
let r = unms({
    baseUrl: 'https://127.0.0.1:443', // The URL of the Unifi Controller
    username: 'ubnt',
    password: 'ubnt',
    // debug: true, // More debug of the API (uses the debug module)
    // debugNet: true // Debug of the network requests (uses request module)
});
r.stat_sessions()
    .then((data) => {
        console.log('Stat sessions', data);
        return r.stat_allusers();
    })
    .then((data) => {
        console.log('AP data', data);
    })
    .catch((err) => {
        console.log('Error', err);
    })

Rebuild Readme.md

If you want to modify the README.md file for any reason (added jsdoc comment somewhere or have done change to README.hbs) please run

npm run readme

API

UnmsAPI(options) ⇒

The main class and the initialization of the UNMS Access

Kind: global function
Returns: this

| Param | Type | Description | | --- | --- | --- | | options | object | the options during initialization | | options.baseUrl | string | the URL where the Unifi controller is. Default https://127.0.0.1:443 | | options.username | string | default username | | options.password | string | default password | | options.site | string | default site. Default is "default" | | options.debug | boolean | if the debug log is enabled | | options.debugNet | boolean | if the debug of the request module is enabled |

Example

let UnmsAPI = require('node-unmsapi');
let unifi = UnmsAPI({
   baseUrl: 'https://127.0.0.1:443', // The URL of the Unifi Controller
   username: 'ubnt',
   password: 'ubnt',
   // debug: true, // More debug of the API (uses the debug module)
   // debugNet: true // Debug of the network requests (uses request module)
});

unmsAPI.debugging(enable) ⇒ undefined

Enable or disable the debug of the module

Kind: instance method of UnmsAPI

| Param | Type | Description | | --- | --- | --- | | enable | boolean | Enable or disable the debugging |

unmsAPI.netsite(url, jsonParams, headers, method, site) ⇒ Promise

Generic network operation, executing UNMS command under /v2.1//sites/... rest api

Kind: instance method of UnmsAPI

| Param | Type | Description | | --- | --- | --- | | url | string | The right part of the URL (/api/s/{site}/ is automatically added) | | jsonParams | object | optional. Default undefined. If it is defined and it is object, those will be the JSON POST attributes sent to the URL and the the default method is changed from GET to POST | | headers | object | optional. Default {}. HTTP headers that we require to be sent in the request | | method | object | optional. Default undefined. The HTTP request method. If undefined, then it is automatic. If no jsonParams specified, it will be GET. If jsonParams are specified it will be POST | | site | string | optional. The {site} atribute of the request. If not specified, it is taken from the UnifiAPI init options, where if it is not specified, it is "default" |

Example

unifi.netsite('/cmd/stamgr', { cmd: 'authorize-guest', mac: '00:01:02:03:04:05', minutes: 60 }, {}, 'POST', 'default')
    .then(data => console.log('Success', data))
    .catch(error => console.log('Error', error));

unmsAPI.login(username, password) ⇒ Promise

Explicit login to the controller. It is not necessary, as every other method calls implicid login (with the default username and password) before execution

Kind: instance method of UnmsAPI
Returns: Promise - success or failure

| Param | Type | Description | | --- | --- | --- | | username | string | The username | | password | string | The password |

Example

unifi.login(username, password)
    .then(data => console.log('success', data))
    .catch(err => console.log('Error', err))

unmsAPI.logout()

Logout of the controller

Kind: instance method of UnmsAPI
Example

unms.logout()
    .then(() => console.log('Success'))
    .catch(err => console.log('Error', err))

unmsAPI.list_sites() ⇒ Promise

List sites

Kind: instance method of UnmsAPI
Returns: Promise - Promise
Example

unifi.list_sites()
    .then(done => console.log('Success',done))
    .catch(err => console.log('Error',err))

unmsAPI.list_devices() ⇒ Promise

List devices

Kind: instance method of UnmsAPI
Returns: Promise - Promise
Example

unifi.list_devices()
    .then(done => console.log('Success',done))
    .catch(err => console.log('Error',err))

unmsAPI.list_logs(count, which) ⇒ Promise

List logs

Kind: instance method of UnmsAPI
Returns: Promise - Promise

| Param | Description | | --- | --- | | count | how many to return per page. default is 100000 | | which | page to return (default 1) |

Example

unifi.list_logs()
    .then(done => console.log('Success',done))
    .catch(err => console.log('Error',err))

unmsAPI.list_outages(count, which) ⇒ Promise

List outages

Kind: instance method of UnmsAPI
Returns: Promise - Promise

| Param | Description | | --- | --- | | count | how many to return per page. default is 100000 | | which | page to return (default 1) |

Example

unifi.list_outages()
    .then(done => console.log('Success',done))
    .catch(err => console.log('Error',err))

unmsAPI.list_settings() ⇒ Promise

List settings

Kind: instance method of UnmsAPI
Returns: Promise - Promise
Example

unifi.list_outages()
    .then(done => console.log('Success',done))
    .catch(err => console.log('Error',err))

unmsAPI.keepalive() ⇒ Promise

Do keepalive

Kind: instance method of UnmsAPI
Returns: Promise - Promise
Example

unifi.list_outages()
    .then(done => console.log('Success',done))
    .catch(err => console.log('Error',err))