{"id":27963227,"url":"https://github.com/delian/node-unifiapi","last_synced_at":"2025-08-14T04:10:22.881Z","repository":{"id":56142299,"uuid":"79998039","full_name":"delian/node-unifiapi","owner":"delian","description":"UniFi API ported to Node.JS","archived":false,"fork":false,"pushed_at":"2020-11-24T15:59:56.000Z","size":3887,"stargazers_count":51,"open_issues_count":20,"forks_count":19,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-05-07T19:58:23.617Z","etag":null,"topics":["api","controller","ubiqiuiti","unifi","wifi"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/delian.png","metadata":{"files":{"readme":"README.hbs","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-25T08:57:28.000Z","updated_at":"2025-01-24T03:52:06.000Z","dependencies_parsed_at":"2022-08-15T13:30:59.300Z","dependency_job_id":null,"html_url":"https://github.com/delian/node-unifiapi","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delian%2Fnode-unifiapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delian%2Fnode-unifiapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delian%2Fnode-unifiapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/delian%2Fnode-unifiapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/delian","download_url":"https://codeload.github.com/delian/node-unifiapi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252949273,"owners_count":21830150,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","controller","ubiqiuiti","unifi","wifi"],"created_at":"2025-05-07T19:58:30.071Z","updated_at":"2025-05-07T19:58:30.852Z","avatar_url":"https://github.com/delian.png","language":"JavaScript","funding_links":[],"categories":["API Libraries"],"sub_categories":["Node.js / JavaScript"],"readme":"# node-unifiapi\nUniFi API ported to Node.JS\n\nThis library is a rewrite of the PHP based UniFi-API-Browser written in JavaScript for Node-JS.\n\nIt 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.\n\n## Major features\n\n* Implements the major (if not all) calls to the REST API of the Ubiquiti for Unifi Controller\n* 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\n* Supports SSH access to the devices that support it (mostly UAP) over WebRTC\n* Supports Plug-in replacement for the WebRTC module (tested with electron-webrtc) in case wrtc doesn't work for you for some reason\n\n## Warning\nQuite unstable mostly due to the instability of the WebRTC implementation in Node.JS.\nAlso highly incompleted and untested. Any help appreciated!\n\n## Installation\nTo install run:\n\n    npm install node-unifiapi --save\n\nThe installation DOES NOT depend on the Node's wrtc module anymore.\nIf 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.\n\nTo install node-webrtc do:\n\n    npm install node-webrtc --save\n\nThe install requirements for node-webrtc are visible here [node-webrtc](https://github.com/js-platform/node-webrtc). Please consult with the installation requirements of this module in order to be able to install it.\n\n### XOpenDisplay Error\nA frequent error caused by node-webrtc module is the one defined in issue [#281](https://github.com/js-platform/node-webrtc/issues/281)\n\n    node: symbol lookup error: [local-path]/build/wrtc/v0.0.61/Release/node-v47-linux-x64/wrtc.node: undefined symbol: XOpenDisplay\n\nIt happens mostly on Linux, almost exquisively if the Linux have X11 subsystem, although it is not caused directly by it (but a bad linking).\nThe 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.\n\n### Segmentation errors\nAgain, the node-wrtc module is quite unstable sometimes. I find it best working on OSX or Linux (Linux Server, without X11 libraries) with the\nprebuilt binary images (which for the moment requires node version 6.9 maximum for Linux).\nThe problem with this instability seems to be well known to the wrtc community but I cannot predict when it will be fixed.\n\nHowever, the unifiapi module uses the standart webrtc api, so it could work with any webrtc module with the standard api.\n\nFollowing is an example with electron-webrtc module:\n\n   npm install electron-webrtc\n\nAnd then a test (example) code:\n\n    let cloud = require('node-unifiapi/cloudapi');\n    let wrtc = require('electron-webrtc')({ headless: true });\n\n    let r = cloud({ device-id: 'xxx-xxx-xx-xx-xx-xx', username: 'myuser', password: 'mypass', webrtc: wrtc, waiter: 1000 }).api;\n\n    r.stat_sessions().then(data =\u003e console.log('Success', data).catch(err =\u003e console.log('Error', err);\n\n\nThe 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.\n\n## Test from CLI\nThere is a sister project available here [https://github.com/delian/unificli](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.\n\n## Usage\n\nAll the API are Promises\n\n### Direct access to Ubiquiti Unifi Controller\nIf you have a direct access to Ubiquiti Unifi Controller, you could use the following API:\n\n    let unifi = require('node-unifiapi');\n    let r = unifi({\n        baseUrl: 'https://127.0.0.1:8443', // The URL of the Unifi Controller\n        username: 'ubnt',\n        password: 'ubnt',\n        // debug: true, // More debug of the API (uses the debug module)\n        // debugNet: true // Debug of the network requests (uses request module)\n    });\n    r.stat_sessions()\n        .then((data) =\u003e {\n            console.log('Stat sessions', data);\n            return r.stat_allusers();\n        })\n        .then((data) =\u003e {\n            console.log('AP data', data);\n        })\n        .catch((err) =\u003e {\n            console.log('Error', err);\n        })\n\n### Access via Unifi Cloud and WebRTC\nIf 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:\n\n    let cloud = require('node-unifiapi/cloudapi');\n    let r = cloud({\n        deviceId: '801bb78e12c80000000001a22aea000000000203c905000000066660aaaa', // The cloud id of the device\n        username: 'clouduser',\n        password: 'cloudpass',\n        // debug: true, // More debug of the API (uses the debug module)\n        // debugNet: true // Debug of the network requests\n    });\n    r.api.stat_sessions()\n        .then((data) =\u003e {\n            console.log('Stat sessions', data);\n            return r.api.stat_allusers();\n        })\n        .then((data) =\u003e {\n            console.log('AP data', data);\n        })\n        .catch((err) =\u003e {\n            console.log('Error', err);\n        })\n\nBe 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.\n\n# Rebuild Readme.md\nIf you want to modify the README.md file for any reason (added jsdoc comment somewhere or have done change to README.hbs) please run\n\n    npm run readme\n\n# API\n\n{{\u003emain}}\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdelian%2Fnode-unifiapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdelian%2Fnode-unifiapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdelian%2Fnode-unifiapi/lists"}