delian / node-unifiapi

UniFi API ported to Node.JS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

node-unifiapi

UniFi API ported to Node.JS

This library is a rewrite of the PHP based UniFi-API-Browser written in JavaScript for Node-JS.

It is mimicking the UniFi-API-Browser API calls (the same commands the same effects) for Ubiquiti Unifi Controller versions 4 and 5 with addition of few more generic calls.

Major features

  • Implements the major (if not all) calls to the REST API of the Ubiquiti for Unifi Controller
  • Supports WebRTC (over the Ubiquiti Unifi Cloud) protocol. If you have your devices registerred in the Unifi Cloud you can access them and execute the same REST API calls over WebRTC
  • Supports SSH access to the devices that support it (mostly UAP) over WebRTC
  • Supports Plug-in replacement for the WebRTC module (tested with electron-webrtc) in case wrtc doesn't work for you for some reason

Warning

Quite unstable mostly due to the instability of the WebRTC implementation in Node.JS. Also highly incompleted and untested. Any help appreciated!

Installation

To install run:

npm install node-unifiapi --save

The installation DOES NOT depend on the Node's wrtc module anymore. If you want to use the WebRTC functionality (Unifi cloudapi and SSH tunnels to device) you have to install webrtc module, and if this module is not node-webrtc you have to explicitly specify it according to the documentation.

To install node-webrtc do:

npm install node-webrtc --save

The install requirements for node-webrtc are visible here node-webrtc. Please consult with the installation requirements of this module in order to be able to install it.

XOpenDisplay Error

A frequent error caused by node-webrtc module is the one defined in issue #281

node: symbol lookup error: [local-path]/build/wrtc/v0.0.61/Release/node-v47-linux-x64/wrtc.node: undefined symbol: XOpenDisplay

It happens mostly on Linux, almost exquisively if the Linux have X11 subsystem, although it is not caused directly by it (but a bad linking). The easiest method to avoid it is to use non desktop (non X11 based) Linux distribution, like Ubuntu Server. We all hope that in version 0.0.62 of the node-webrtc module this issue will be fixed.

Segmentation errors

Again, the node-wrtc module is quite unstable sometimes. I find it best working on OSX or Linux (Linux Server, without X11 libraries) with the prebuilt binary images (which for the moment requires node version 6.9 maximum for Linux). The problem with this instability seems to be well known to the wrtc community but I cannot predict when it will be fixed.

However, the unifiapi module uses the standart webrtc api, so it could work with any webrtc module with the standard api.

Following is an example with electron-webrtc module:

npm install electron-webrtc

And then a test (example) code:

let cloud = require('node-unifiapi/cloudapi');
let wrtc = require('electron-webrtc')({ headless: true });

let r = cloud({ device-id: 'xxx-xxx-xx-xx-xx-xx', username: 'myuser', password: 'mypass', webrtc: wrtc, waiter: 1000 }).api;

r.stat_sessions().then(data => console.log('Success', data).catch(err => console.log('Error', err);

The waiter property sets delay between every command sent to the webrtc in ms. I found electron-webrtc working better, if there is at least 500ms delay between the calls.

Test from CLI

There is a sister project available here https://github.com/delian/unificli which provides CLI tool where all (or most) of the calls of this API are exposed as REPL CLI commands one could use to test.

Usage

All the API are Promises

Direct access to Ubiquiti Unifi Controller

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

let unifi = require('node-unifiapi');
let r = unifi({
    baseUrl: 'https://127.0.0.1:8443', // 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);
    })

Access via Unifi Cloud and WebRTC

If you have to access the Unifi Controller if it is behind NAT and you need to use WebRTC to access it or known only via Unifi Cloud:

let cloud = require('node-unifiapi/cloudapi');
let r = cloud({
    deviceId: '801bb78e12c80000000001a22aea000000000203c905000000066660aaaa', // The cloud id of the device
    username: 'clouduser',
    password: 'cloudpass',
    // debug: true, // More debug of the API (uses the debug module)
    // debugNet: true // Debug of the network requests
});
r.api.stat_sessions()
    .then((data) => {
        console.log('Stat sessions', data);
        return r.api.stat_allusers();
    })
    .then((data) => {
        console.log('AP data', data);
    })
    .catch((err) => {
        console.log('Error', err);
    })

Be careful - when we use the cloud access all the Unifi calls are available under the .api property, to not confuse with the API calls that are related to the cloud management itself.

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

Functions

UnifiAPI(options)

The main class and the initialization of the Unifi Access

list_settings(site)Promise

Alias to list_settings. Retrieve array with settings defined by setting key.

SSH(mac, uuid, stun, turn, username, password, site, autoclose, webrtc, waiter)SSHSession

Open SSH tunnel to a device managed by the controller (currently only Unifi AP) using WebRTC

CloudAPI(options)

Cloud API interface. Under the .api method there will be all of the UnifiAPI calls (over WebRTC)

UnifiAPI(options) ⇒

The main class and the initialization of the Unifi 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:8443
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 UnifiAPI = require('node-unifiapi');
let unifi = UnifiAPI({
   baseUrl: 'https://127.0.0.1:8443', // 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)
});

unifiAPI.debugging(enable) ⇒ undefined

Enable or disable the debug of the module

Kind: instance method of UnifiAPI

Param Type Description
enable boolean Enable or disable the debugging

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

Generic network operation, executing Ubiquiti command under /api/s/{site}/... rest api

Kind: instance method of UnifiAPI

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));

unifiAPI.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 UnifiAPI
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))

unifiAPI.logout()

Logout of the controller

Kind: instance method of UnifiAPI
Example

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

unifiAPI.authorize_guest(mac, minutes, up, down, mbytes, apmac, site) ⇒ Promise

Authorize guest by a MAC address

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
mac string mac address of the guest - mandatory
minutes string minutes for the authorization - optional, default 60 min
up string upstream bandwidth in Kbps. Default no limit
down string downstream bandwidth in Kbps. Default no _limit
mbytes string download limit in Mbytes. Default no limit
apmac string to which mac address the authorization belongs. Default any
site string to which site (Ubiquiti) the command will be applied if it is different than the default

Example

unifi.authorize_guest('01:02:aa:bb:cc')
    .then(data => console.log('Successful authorization'))
    .catch(err => console.log('Error', err))

unifiAPI.unauthorize_guest(mac, site) ⇒ Promise

De-authorize guest by a MAC address

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
mac string the mac address
site site Ubiquiti site, if different from default - optional

Example

unifi.unauthorize_guest('00:01:02:03:aa:bb')
    .then(done => console.log('Success', done))
    .catch(err => console.log('Error', err))

unifiAPI.kick_sta(mac, site) ⇒ Promise

Kick a client (station) of the network. This will disconnect a wireless user if it is connected

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
mac string Mac address
site string Ubiquiti site, if different from default - optional

Example

unifi.kick_sta('00:00:11:22:33:44')
    .then(done => console.log('Success', done))
    .catch(err => console.log('Error', err))

unifiAPI.terminate_guest(id, site) ⇒ Promise

Terminate access of a Guest (logged in via Guest Authorization). It kicks it out of the wireless and authroization

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
id string the ID of the guest that have to be kicked out
site string Ubiquiti site, if different from default - optional

Example

unifi.terminate_guest('aa01af0133d334d77d')
    .this(done => console.log('Success', done))
    .catch(err => console.log('Error', err))

unifiAPI.block_sta(mac, site) ⇒ Promise

Block station of the network

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
mac string Mac address
site string Ubiquiti site, if different from default - optional

Example

unifi.block_sta('00:01:02:03:04:05')
    .then(done => console.log('Success',done))
    .catch(err => console.log('Error', err))

unifiAPI.unblock_sta(mac, site) ⇒ Promise

Unblock station of the network

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
mac string Mac address
site string Ubiquiti site, if different from default - optional

Example

unifi.block_sta('00:01:02:03:04:05')
    .then(done => console.log('Success',done))
    .catch(err => console.log('Error', err))

unifiAPI.set_sta_note(user, note, site) ⇒ Promise

Set or remove Note to a station

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
user string User ID
note string Note
site string Ubiquiti site, if different from default - optional

Example

unifi.set_sta_note('aabbaa0102aa03aa3322','Test note')
    .then(done => console.log('Success',done))
    .catch(err => console.log('Error',err))

Example

unifi.set_sta_note('aabbaa0102aa03aa3322','') // remove note
    .then(done => console.log('Success',done))
    .catch(err => console.log('Error',err))

unifiAPI.set_sta_name(user, name, site) ⇒ Promise

Set or remove Name to a station

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
user string User ID
name string Name
site string Ubiquiti site, if different from default - optional

Example

unifi.set_sta_name('aabbaa0102aa03aa3322','Central Access Point')
    .then(done => console.log('Success',done))
    .catch(err => console.log('Error',err))

Example

unifi.set_sta_name('aabbaa0102aa03aa3322','') // remove name
    .then(done => console.log('Success',done))
    .catch(err => console.log('Error',err))

unifiAPI.stat_sessions(start, end, type, site) ⇒ Promise

List client sessions

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
start number Start time in Unix Timestamp - Optional. Default 7 days ago
end number End time in Unix timestamp - Optional. Default - now
type string Sessions type. Optional. Default all
site string Ubiquiti site, if different from default - optional

Example

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

unifiAPI.stat_daily_site(start, end, attrs, site) ⇒ Promise

List daily site statistics

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
start number Start time in Unix Timestamp - Optional. Default 7 days ago
end number End time in Unix timestamp - Optional. Default - now
attrs array What attributes we are quering for. Optional. Default [ 'bytes', 'wan-tx_bytes', 'wan-rx_bytes', 'wlan_bytes', 'num_sta', 'lan-num_sta', 'wlan-num_sta', 'time' ]
site string Ubiquiti site, if different from default - optional

Example

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

unifiAPI.stat_hourly_site(start, end, attrs, site) ⇒ Promise

List hourly site statistics

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
start number Start time in Unix Timestamp - Optional. Default 7 days ago
end number End time in Unix timestamp - Optional. Default - now
attrs array What attributes we are quering for. Optional. Default [ 'bytes', 'wan-tx_bytes', 'wan-rx_bytes', 'wlan_bytes', 'num_sta', 'lan-num_sta', 'wlan-num_sta', 'time' ]
site string Ubiquiti site, if different from default - optional

Example

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

unifiAPI.stat_hourly_ap(start, end, attrs, site) ⇒ Promise

List hourly site statistics for ap

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
start number Start time in Unix Timestamp - Optional. Default 7 days ago
end number End time in Unix timestamp - Optional. Default - now
attrs array What attributes we are quering for. Optional. Default [ 'bytes', 'num_sta', 'time' ]
site string Ubiquiti site, if different from default - optional

Example

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

unifiAPI.stat_sta_sessions_latest(mac, limit, sort, site) ⇒ Promise

Last station sessions

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
mac string Mac address
limit number How many sessions. Optional. Default 5
sort string Sorting. Optional. Default Ascending (asc)
site string Ubiquiti site, if different from default - optional

Example

unifi.stat_sta_sessions_latest('00:01:02:03:04:05', 10)
    .then(done => console.log('Success', done))
    .catch(err => console.log('Error',err))

unifiAPI.stat_auths(start, end, site) ⇒ Promise

List authorizations

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
start number Start time in Unix Timestamp - Optional. Default 7 days ago
end number End time in Unix timestamp - Optional. Default - now
site string Ubiquiti site, if different from default - optional

Example

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

unifiAPI.stat_allusers(historyhours, site) ⇒ Promise

List all users

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
historyhours number How many hours back to query. Optional. Default 8670
site string Ubiquiti site, if different from default - optional

Example

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

unifiAPI.list_guests(historyhours, site) ⇒ Promise

List of guests (authorized via the guest portal)

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
historyhours number How many hours back to query. Optional. Default 8670
site string Ubiquiti site, if different from default - optional

Example

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

unifiAPI.list_guests2(historyhours, site) ⇒ Promise

List of guests (authorized via the guest portal) but with modern internal api

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
historyhours number How many hours back to query. Optional. Default 8670
site string Ubiquiti site, if different from default - optional

Example

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

unifiAPI.list_clients(mac, site) ⇒ Promise

List of (all) clients per station

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
mac string Mac address
site string Ubiquiti site, if different from default - optional

Example

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

unifiAPI.list_some_clients(macs, ap, site) ⇒ Promise

List of group of clients per station

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
macs string String mac or array of mac addresses as strings, to get information about them
ap string Station man address
site string Ubiquiti site, if different from default - optional

Example

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

unifiAPI.stat_client(mac, site) ⇒ Promise

Statistics of (all) clients per station

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
mac string Mac address
site string Ubiquiti site, if different from default - optional

Example

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

unifiAPI.list_usergroup(site) ⇒ Promise

List of the usergroups

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
site string Ubiquiti site, if different from default - optional

Example

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

unifiAPI.set_usergroup(userid, groupid, site) ⇒ Promise

Add user to a group

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
userid string ID of the user
groupid string ID of the group
site string Ubiquiti site, if different from default - optional

Example

unifi.set_usergroup('11aa22bb33cc44dd55ee66ff', '112233445566778899aabb')
    .then(done => console.log('Success',done))
    .catch(err => console.log('Error',err))

unifiAPI.list_health(site) ⇒ Promise

List health

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
site string Ubiquiti site, if different from default - optional

Example

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

unifiAPI.list_dashboard(site) ⇒ Promise

List dashboard

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
site string Ubiquiti site, if different from default - optional

Example

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

unifiAPI.list_users(site) ⇒ Promise

List users

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
site string Ubiquiti site, if different from default - optional

Example

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

unifiAPI.list_aps(mac, site) ⇒ Promise

List APs

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
mac string AP mac/id, Optional
site string Ubiquiti site, if different from default - optional

Example

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

unifiAPI.list_rogueaps(within, site) ⇒ Promise

List Rogue APs

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
within number For how many hours back. Optional. Default 24h
site string Ubiquiti site, if different from default - optional

Example

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

unifiAPI.list_sites() ⇒ Promise

List sites

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

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

unifiAPI.stat_sites() ⇒ Promise

Sites stats

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

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

unifiAPI.add_site(name, description, site) ⇒ Promise

Add new site

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
name string name
description string description - optional
site string Ubiquiti site to query, if different from default - optional

Example

unifi.add_site('mysite','Experimental site')
    .then(done => console.log('Success',done))
    .catch(err => console.log('Error',err))

unifiAPI.remove_site(name, site) ⇒ Promise

Remove site

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
name string name
site string Ubiquiti site to query, if different from default - optional

Example

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

unifiAPI.list_wlan_groups(site) ⇒ Promise

List WLANGroups

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
site string Ubiquiti site to query, if different from default - optional

Example

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

unifiAPI.stat_sysinfo(site) ⇒ Promise

Stat Sysinfo

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
site string Ubiquiti site to query, if different from default - optional

Example

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

unifiAPI.list_self(site) ⇒ Promise

Get information aboult self (username, etc)

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
site string Ubiquiti site to query, if different from default - optional

Example

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

unifiAPI.list_networkconf(site) ⇒ Promise

Get information aboult the network configuration

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
site string Ubiquiti site to query, if different from default - optional

Example

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

unifiAPI.stat_voucher(createtime, site) ⇒ Promise

Get accounting / status of the vouchers

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
createtime number Unixtimestamp since when we return information about the vouchers. Optional. Default any
site string Ubiquiti site to query, if different from default - optional

Example

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

unifiAPI.stat_payment(within, site) ⇒ Promise

Get accounting / status of the payments

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
within number how many hours back we query. Optional. Default any
site string Ubiquiti site to query, if different from default - optional

Example

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

unifiAPI.create_hotspot(name, password, note, site) ⇒ Promise

Create HotSpot (version 1)

Kind: instance method of UnifiAPI
Returns: Promise - Promise
Todo

  • Check if the URL of the rest service is correct
  • Test that it is working
Param Type Description
name string name
password string password
note string Note (optional)
site string Ubiquiti site to query, if different from default - optional

Example

unifi.create_hotspot('myhotspot', 'password', 'note')
    .then(done => console.log('Success',done))
    .catch(err => console.log('Error',err))

unifiAPI.list_hotspot(site) ⇒ Promise

List all of the hotspots (v1)

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
site string Ubiquiti site to query, if different from default - optional

Example

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

unifiAPI.create_voucher(count, minutes, quota, note, up, down, mbytes, site) ⇒ Promise

Create vouchers. Generate a set of vouchers

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
count number how many vouchers to generate. Optional. default is 1
minutes number how long the voucher may be active after activation in minutes. Optional. default is 60 minutes
quota number how many times a user may reuse (login with) this voucher. Default 0 = unlimited. 1 means only once. 2 means two times and so on
note string the note of the voucher. Optional
up number Upstream bandwidth rate limit in Kbits. Optional. Default - no limit
down number Downstream bandwidth rate limit in Kbits. Optional. Default - no limit
mbytes number Limit of the maximum download traffic in Mbytes. Optional. Default - no limit
site string Ubiquiti site to query, if different from default - optional

Example

unifi.create_voucher(10, 2880, 1, 'Test vouchers', 1000, 2000, 250)
    .then(done => console.log('Success',done))
    .catch(err => console.log('Error',err))

unifiAPI.revoke_voucher(voucher_id, site) ⇒ Promise

Revoke Voucher. Voucher revoking is the same as deleting the voucher. In most of the cases the authorized user is kicked out of the network too

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
voucher_id string description
site string Ubiquiti site to query, if different from default - optional

Example

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

unifiAPI.list_portforwarding(site) ⇒ Promise

List port forwarding configuration

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
site string Ubiquiti site to query, if different from default - optional

Example

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

unifiAPI.list_dynamicdns(site) ⇒ Promise

List dynamic dns configuration

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
site string Ubiquiti site to query, if different from default - optional

Example

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

unifiAPI.list_portconf(site) ⇒ Promise

List network port configuration

Kind: instance method of UnifiAPI
Returns: Promise - Promise
Todo

  • Test it
Param Type Description
site string Ubiquiti site to query, if different from default - optional

Example

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

unifiAPI.list_extension(site) ⇒ Promise

List extensions

Kind: instance method of UnifiAPI
Returns: Promise - Promise
Todo

  • Learn more what exactly is this
Param Type Description
site string Ubiquiti site to query, if different from default - optional

Example

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

unifiAPI.list_settings(site) ⇒ Promise

Get array with all the settings refered by settings key

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
site string Ubiquiti site to query, if different from default - optional

Example

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

unifiAPI.restart_ap(mac, site) ⇒ Promise

Restart Wireless Access Point

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
mac string mac address of the AP
site string Ubiquiti site to query, if different from default - optional

Example

unifi.restart_ap('00:01:02:03:aa:04')
    .then(done => console.log('Success',done))
    .catch(err => console.log('Error',err))

unifiAPI.disable_ap(ap_id, disable, site) ⇒ Promise

Disable Wireless Access Point

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
ap_id string The internal ID of the AP
disable boolean Shall we disable it. Optional. Default true. If false, the AP is enabled
site string Ubiquiti site to query, if different from default - optional

Example

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

unifiAPI.enable_ap(ap_id, disable, site) ⇒ Promise

Enable Wireless Access Point

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
ap_id string The internal ID of the AP
disable boolean Shall we disable it. Optional. Default true. If false, the AP is enabled
site string Ubiquiti site to query, if different from default - optional

Example

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

unifiAPI.set_locate_ap(mac, site) ⇒ Promise

Locate Wireless Access Point. The Access Point will start blinking

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
mac string mac of the AP
site string Ubiquiti site to query, if different from default - optional

Example

unifi.set_locate_ap('00:01:aa:03:04:05')
    .then(done => console.log('Success',done))
    .catch(err => console.log('Error',err))

unifiAPI.unset_locate_ap(mac, site) ⇒ Promise

Turn off Locate Wireless Access Point. The Access Point will stop blinking

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
mac string mac of the AP
site string Ubiquiti site to query, if different from default - optional

Example

unifi.unset_locate_ap('00:01:aa:03:04:05')
    .then(done => console.log('Success',done))
    .catch(err => console.log('Error',err))

unifiAPI.site_ledson(site) ⇒ Promise

All devices in the site group will start blinking

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
site string Ubiquiti site to query, if different from default - optional

Example

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

unifiAPI.site_ledsoff(site) ⇒ Promise

All devices in the site group will stop blinking

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
site string Ubiquiti site to query, if different from default - optional

Example

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

unifiAPI.set_ap_radiosettings(ap_id, radio, channel, ht, tx_power_mode, tx_power, site) ⇒ Promise

Change AP wireless settings

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
ap_id string internal id of the AP
radio string The radio type. Supports ng or ac. Default ng. Optional
channel number Wireless channel. Optional. Default 1. Could be string 'auto'
ht number HT width in MHz. 20, 40, 80, 160. Optional. Default 20
tx_power_mode number TX Power Mode. Optional. Default 0
tx_power number TX Power. Optional. Default 0
site string Ubiquiti site to query, if different from default - optional

Example

unifi.set_ap_radiosettings('aa0101023faabbaacc0c0', 'ng', 3, 20)
    .then(done => console.log('Success',done))
    .catch(err => console.log('Error',err))

unifiAPI.get_settings_by_key(key, site) ⇒ Promise

Retrieve settings by a specific settings key. Only elements with this settings key will be returned in the array. Usually 1 or 0 Typical keys are mgmt, snmp, porta, locale, rsyslogd, auto_speedtest, country, connectivity

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
key string key
site string Ubiquiti site to query, if different from default - optional

Example

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

unifiAPI.set_settings(key, obj, site) ⇒ Promise

Set settings by key modifies properties of the settings, defined by key

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
key string key
obj object object of properties that overwrite the original values
site string Ubiquiti site to query, if different from default - optional

Example

unifi.set_settings_by_key('mgmt', { auto_upgrade: true })
    .then(done => console.log('Success',done))
    .catch(err => console.log('Error',err))

unifiAPI.set_guest_access(obj, guest_id, site_id, site) ⇒ Promise

Set Guest Settings and Guest Access Portal are created with this method

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
obj object Object of properties that modify the original values
obj.auth string Optional. Type of authentication. hotspot, radius, none, .... Default hotspot
obj.expire string Optional. How long the authentication is valid in minutes. Default 480 (8h)
obj.facebook_enabled boolean Optional. Allow authentication with facebook. Default false
obj.google_enabled boolean Optional. Allow authentication with google+. Default false
obj.payment boolean Optional. Allow payments for authentication. Default false
obj.portal_customized boolean Optional. Customize the auth portal. Default false
obj.portal_enabled boolean Optional. Enable the portal. Default true
obj.redirect_enabled boolean Optional. Redirect after authentication. Default false
obj.redirect_url string Optional. Redirect URL after successful authentication. Default empty
obj.voucher_enabled boolean Optional. If voucher authentication is enabled. Default false
guest_id string From the get_settings, the ID of the guest settings
site_id string The ID of the current site
site string Ubiquiti site to query, if different from default - optonal

Example

unifi.set_guest_access({ auth: 'hotspot', payment_enabled: true }, 'aabbaa01010203','ccffee0102030303')
    .then(done => console.log('Success',done))
    .catch(err => console.log('Error',err))

unifiAPI.set_guestlogin_settings(portal_enabled, portal_customized, redirect_enabled, redirect_url, x_password, site) ⇒ Promise

Set Guest Login Settings (simplified version)

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
portal_enabled boolean If the portal is enabled. Optional. Default true
portal_customized boolean If the portal is customized. Optional. Default true
redirect_enabled boolean If the redirection is enabled. Optional. Default false
redirect_url string The url for redirection. Optional. Default ''
x_password string Password for the portal. Optional. Default ''
site string Ubiquiti site to query, if different from default - optonal

Example

unifi.set_guestlogin_settings(true, true, true, 'http://news.com')
    .then(done => console.log('Success',done))
    .catch(err => console.log('Error',err))

unifiAPI.rename_ap(ap_id, ap_name, site) ⇒ Promise

Rename Access Point

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
ap_id string Id of the AP
ap_name string New name of the AP
site string Ubiquiti site to query, if different from default - optonal

Example

unifi.rename_ap('ccffee0102030303','My Access Point')
    .then(done => console.log('Success',done))
    .catch(err => console.log('Error',err))

unifiAPI.set_wlansettings(wlan_id, x_password, name, site) ⇒ Promise

Set WLAN Settings

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
wlan_id strings ID of the Wlan
x_password string Password of the WLAN
name string Name of the WLAN
site string Ubiquiti site to query, if different from default - optonal

Example

unifi.set_wlansettings('ccffee0102030303', 'guest', 'GuestWLAN')
    .then(done => console.log('Success',done))
    .catch(err => console.log('Error',err))

unifiAPI.list_events(site) ⇒ Promise

List the Events

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
site string Ubiquiti site to query, if different from default - optonal

Example

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

unifiAPI.list_wlanconf(site) ⇒ Promise

Get WLAN Config. Respond with Array of Wlan configurations

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
site string Ubiquiti site to query, if different from default - optonal

Example

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

unifiAPI.get_wlanconf(site) ⇒ Promise

Get WLAN Config. Second REST option. Respond with Array of Wlan configurations

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
site string Ubiquiti site to query, if different from default - optonal

Example

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

unifiAPI.list_alarms(site) ⇒ Promise

List the Alarms

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
site string Ubiquiti site to query, if different from default - optonal

Example

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

unifiAPI.set_ap_led(ap_id, led_override, site) ⇒ Promise

Set the access point LED

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
ap_id string AP ID
led_override string Do we follow the standard LED config. Options default and overwrite
site string Ubiquiti site to query, if different from default - optonal

Example

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

unifiAPI.set_ap_name(ap_id, name, site) ⇒ Promise

Change the name of an Access Point

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
ap_id string the ID of the AP
name string the new name
site string Ubiquiti site to query, if different from default - optonal

Example

unifi.set_ap_name('12312312312','new ap')
    .then(done => console.log('Success',done))
    .catch(err => console.log('Error',err))

unifiAPI.set_ap_wireless(ap_id, radio, channel, ht, min_rssi, min_rssi_enabled, antenna_gain, tx_power_mode, site) ⇒ Promise

Set wireless properties per AP

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
ap_id string the ID of the AP
radio string radio type. ng/ac/bg. Optional. Default ng
channel number The channel number or auto. Optional. Default auto.
ht number channel width. 20/40/80/160. Optional. Default 20.
min_rssi number Minimal RSSI accepted in dbi. Optional. Default -94
min_rssi_enabled boolean If enabled, drops users bellow that rssi valur. Optional. Default false
antenna_gain number The antenna gain. Optional. Default 6 dbi
tx_power_mode string TX Power Mode. Optional. Default auto
site string Ubiquiti site to query, if different from default - optonal

Example

unifi.set_ap_wireless('12312312312','ng', 3)
    .then(done => console.log('Success',done))
    .catch(err => console.log('Error',err))

unifiAPI.status(site) ⇒ Promise

Check status

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
site string Ubiquiti site to query, if different from default - optonal

Example

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

unifiAPI.set_ap_network(ap_id, type, ip, netmask, gateway, dns1, dns2, site) ⇒ Promise

Configure the network settings of AP/device

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
ap_id string ID of the AP
type string static or dhcp. Optional. Default dhcp
ip string IP address. Optional
netmask string netmask. Optional
gateway string gateway. Optional
dns1 string dns. Optional
dns2 string dns. Optional
site string Ubiquiti site to query, if different from default - optonal

Example

unifi.set_ap_network('00:01:02:03:04:05', 'dhcp')
    .then(done => console.log('Success',done))
    .catch(err => console.log('Error',err))

unifiAPI.request_spectrumscan(mac, site) ⇒ Promise

Request a spectrum scan

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
mac string Mac of the AP
site string Ubiquiti site to query, if different from default - optonal

Example

unifi.request_spectrumscan('00:01:02:03:04:05')
    .then(done => console.log('Success',done))
    .catch(err => console.log('Error',err))

unifiAPI.set_site_descr(description, site) ⇒ Promise

Set description to the site

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
description string description
site string Ubiquiti site to query, if different from default - optonal

Example

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

unifiAPI.set_site_settings(gen_id, site_id, advanced, alerts, auto_upgrade, key, led_enabled, x_ssh_username, x_ssh_password, site) ⇒ Promise

Set settings of the site (optional)

Kind: instance method of UnifiAPI
Returns: Promise - Promise
Todo

  • To be tested and completed
Param Type Description
gen_id string The id of the settings
site_id string The id of the site
advanced boolean advanced options enabled. Optional. default true
alerts boolean alerts enabled. Optional. default true
auto_upgrade boolean auto upgrade of the AP enabled. Optional. default true
key string always mgmt. Optional. default mgmt
led_enabled boolean Led enabled. Optional. default true
x_ssh_username string SSH username. Optional. Default ubnt
x_ssh_password string SSH password. Optional. Default ubnt
site string Ubiquiti site to query, if different from default - optonal

Example

unifi.set_site_settings('0101923920a3a4fbff', '3333923920a3a4fbff', false)
    .then(done => console.log('Success',done))
    .catch(err => console.log('Error',err))

unifiAPI.add_hotspot2(name, network_access_internet, network_type, venue_group, venue_type, site) ⇒ Promise

Add HotSpot 2.0 configuration

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
name string hotspot name. Default hotspot
network_access_internet string Network access
network_type number Network type. Optional. Default 2
venue_group number Venue group. Optional. Default 2
venue_type number Venue type. Optional. Default 0
site string Ubiquiti site to query, if different from default - optonal

Example

unifi.add_hotspot2('hotspot2.0 config')
    .then(done => console.log('Success',done))
    .catch(err => console.log('Error',err))

unifiAPI.list_hotspot2(site) ⇒ Promise

List hotspot 2.0 configurations

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
site string Ubiquiti site to query, if different from default - optonal

Example

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

unifiAPI.delete_hotspot2(site) ⇒ Promise

Delete hotspot 2.0 configuration

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
site string Ubiquiti site to query, if different from default - optonal

Example

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

Example

unifi.list_hotspot2()
    .then(data => unifi.delete_hotspot2(data.data.shift()._id))
    .then(done => console.log('Success',done))
    .catch(err => console.log('Error',err))

unifiAPI.set_hotspot2(hs_id, name, network_access_internet, network_type, venue_group, venue_type, site) ⇒ Promise

Modify Hotspot 2.0 configuration

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
hs_id string Hotspot2.0 config id
name string name. Optional
network_access_internet string Network access. Optional
network_type number Network type. Optional
venue_group number Venue group. Optional
venue_type number Venue type. Optional
site string Ubiquiti site to query, if different from default - optonal

Example

unifi.set_hotspot2('112323322aaaffa191', 'new name')
    .then(done => console.log('Success',done))
    .catch(err => console.log('Error',err))

unifiAPI.remove_wlanconf(id, site) ⇒ Promise

Remove WLAN configuration

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
id string wlan config id
site string Ubiquiti site to query, if different from default - optonal

Example

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

unifiAPI.sdn_register(username, password, site) ⇒ Promise

Register to the SDN (Ubiquiti cloud)

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
username string Cloud username
password string Cloud password
site string Ubiquiti site to query, if different from default - optonal

Example

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

unifiAPI.sdn_unregister(site) ⇒ Promise

Deregister of the SDN (Ubiquiti cloud)

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
site string Ubiquiti site to query, if different from default - optonal

Example

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

unifiAPI.sdn_stat(site) ⇒ Promise

Get information about the Ubiquiti cloud registration

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
site string Ubiquiti site to query, if different from default - optonal

Example

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

unifiAPI.sdn_onoff(enabled, site_id, site) ⇒ Promise

SDN on, off, deregistration

Kind: instance method of UnifiAPI
Returns: Promise - Promise

Param Type Description
enabled boolean Enable SDN or disable it. Default true
site_id string Site id
site string Ubiquiti site to query, if different from default - optonal

Example

unifi.sdn_onoff(true, '00010102221adffaa03')
    .then(done => console.log('Success',done))
    .catch(err => console.log('Error',err))

unifiAPI.extend_voucher(voucher_id, site) ⇒ Promise

Extend voucher

Kind: instance method of UnifiAPI
Returns: Promise - Promise
Todo

  • Test it and verify that the REST url is correct
Param Type Description
voucher_id string voucher id
site string Ubiquiti site to query, if different from default - optonal

Example

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

list_settings(site) ⇒ Promise

Alias to list_settings. Retrieve array with settings defined by setting key.

Kind: global function
Returns: Promise - Promise

Param Type Description
site string Ubiquiti site to query, if different from default - optional

Example

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

SSH(mac, uuid, stun, turn, username, password, site, autoclose, webrtc, waiter) ⇒ SSHSession

Open SSH tunnel to a device managed by the controller (currently only Unifi AP) using WebRTC

Kind: global function
Returns: SSHSession - Return SSHSession object with connect, send, recv, expect, close methods

Param Type Description
mac string The mac address of the AP
uuid string Unique UUID of the session. Optional. Auto generated if undefined
stun string Stun server url. Optional. If undefined, automatically populated
turn string Turn server url. Optional. If undefined, automatically populated
username string Turn username. Optional
password string Turn password. Optional
site string Ubiquiti site to query, if different from default - optonal
autoclose number Timeout (milisec) of inactivity before the session is automatically closed. Optional. Default 30000
webrtc object Object containing initialized WebRTC module. Optional. If not specified wrtc module is used or the one set in the UnifiAPI initialization. Tested with electron-webrtc
waiter number How many ms to wait before the next webrtc API call. Optionl. With wrtc is 100ms. However with electron-webrtc must be more than 1500 to avoid crashing on MAC and sometimes on Linux

Example

let ssh = unifi.connectSSH('00:01:02:03:04:05');
ssh.connect()
    .then((data) => {
        ssh.send('\nls -al\n');
        return ssh.expect('#')
    })
    .then(data => console.log(data))
    .catch(err => console.log('Error', err))

CloudAPI(options) ⇒

Cloud API interface. Under the .api method there will be all of the UnifiAPI calls (over WebRTC)

Kind: global function
Returns: CloudAPI

Param Type Description
options object default parameters to access Unifi Cloud
options.username string Cloud username
options.password string Cloud password
options.debug boolean Debug the module. Optional. Default false
options.deviceId string Default Device Id
options.gzip boolean If gzip is enabled for the cloud messages. Optional. default true
options.webrtc object Reference to WebRTC module for NodeJS. If non specified, wrtc is used. Tested with electron-webrtc
options.waiter object How many ms to wait before WebRTC API call. Necessary for electron-webrtc as too fast calls crash the communication (values > 1000ms must be set for electron-webrtc)

Example

let CloudAPI = require('node-unifiapi/cloudapi');
let cloud = CloudAPI({ deviceId: 'aaaffaad0121212', username: 'clouduser', password: 'cloudpass'});
cloud.self()
    .then(() => cloud.devices())
    .then(data => { console.log('Devices', data); return cloud.api.stat_sessions(); })
    .then(data => console.log('Sessions', data))
    .catch(err => console.log('Error', err))

cloudAPI.debugging(enabled) ⇒ undefined

Enable or disable debugging

Kind: instance method of CloudAPI

Param Type Description
enabled boolean Enable or Disable debugging

cloudAPI.login(username, password) ⇒ Promise

Explicit login. Optional call as implicit login is always in place

Kind: instance method of CloudAPI
Returns: Promise - Promise

Param Type Description
username string username if different from default.
password string password if different from default.

Example

cloud.login()
    .then(done => console.log('Success', done))
    .catch(err => console.log('Error', err))

cloudAPI.logout() ⇒ Promise

Explicit logout

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

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

cloudAPI.self() ⇒ Promise

Check information about self

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

cloud.self()
    .then(done => console.log('Success', done))
    .catch(err => console.log('Error', err))

cloudAPI.devices() ⇒ Promise

List registered devices / controllers

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

cloud.devices()
    .then(done => console.log('Success', done))
    .catch(err => console.log('Error', err))

cloudAPI.delete_device(device_id) ⇒ Promise

Forget device/controller

Kind: instance method of CloudAPI
Returns: Promise - Promise

Param Type Description
device_id string ID of the device

Example

cloud.delete_device('aa8181092821922221a')
    .then(done => console.log('Success', done))
    .catch(err => console.log('Error', err))

About

UniFi API ported to Node.JS

License:GNU General Public License v3.0


Languages

Language:JavaScript 100.0%