{"id":18764087,"url":"https://github.com/oddbit/unifi-js","last_synced_at":"2025-04-13T04:33:05.248Z","repository":{"id":57132781,"uuid":"104951613","full_name":"oddbit/unifi-js","owner":"oddbit","description":"An easy to use and Typscript friendly API client for managing UBNT UniFi accesspoints.","archived":false,"fork":false,"pushed_at":"2017-10-02T05:18:01.000Z","size":59,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-04-10T15:38:39.917Z","etag":null,"topics":["nodejs","npm-module","npm-package","typescript","ubnt","unifi","unifi-controller"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@oddbit/unifi","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oddbit.png","metadata":{"files":{"readme":"README.md","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-09-27T00:22:22.000Z","updated_at":"2021-04-22T08:00:15.000Z","dependencies_parsed_at":"2022-09-03T11:42:31.681Z","dependency_job_id":null,"html_url":"https://github.com/oddbit/unifi-js","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oddbit%2Funifi-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oddbit%2Funifi-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oddbit%2Funifi-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oddbit%2Funifi-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oddbit","download_url":"https://codeload.github.com/oddbit/unifi-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248664407,"owners_count":21141948,"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":["nodejs","npm-module","npm-package","typescript","ubnt","unifi","unifi-controller"],"created_at":"2024-11-07T18:28:39.657Z","updated_at":"2025-04-13T04:33:05.014Z","avatar_url":"https://github.com/oddbit.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @oddbit/unifi\n [![npm version](https://img.shields.io/npm/v/@oddbit/unifi.svg)](https://www.npmjs.com/package/@oddbit/unifi) ![npm](https://img.shields.io/npm/l/@oddbit/unifi.svg)\n\nAn easy to use and Typscript friendly API client for managing UBNT UniFi accesspoints.\n\n\nThe UniFi API is officially not very well documented, the project started out from [this shell script](https://dl.ubnt.com/unifi/5.4.16/unifi_sh_api) but I've found that the source code of the PHP project\n[UniFi-API-browser](https://github.com/Art-of-WiFi/UniFi-API-browser) is the best API documentation\nat the moment. Thanks guys!\n\n## Actions\nThe following actions are supported.\n\n- Authorization\n    - Login\n    - Logout\n- Clients (STA/connected devices)\n    - Reconnect client\n    - List clients\n    - Get client\n    - Block client\n    - Unblock client\n    - Set or remove client alias\n    - Set or remove client notes\n- Hotspot guest access\n    - Authorize guest\n    - Unauthorize guest\n    - List vouchers\n    - Create vouchers\n    - Delete vouchers\n- System\n    - Get UniFi controller system info\n    - List sites\n    - List access points with device info\n    - List sessions\n\n## How to use it\n\nBelow is a simple example of synchronous communication with the UniFI controller to authorize a guest (device) at the hotspot.\n\n### Basic\nThe basics of how to create a controller reference and login / logout.\n\n```typescript\nimport * as unifi from \"@oddbit/unifi\";\n\nconst controller = new unifi.UnifiController({\n    host: \"10.11.12.13\",\n    isSelfSigned: true,\n    siteName: \"default\"\n});\n\nawait controller.login(\"admin\", \"secretPassword\");\n// ...\n// Work with the controller\n// ...\nawait controller.logout();\n```\n\n### Discovering controller information\nIn some cases it can be good to first look up information about the site and update configuration accordingly.\nThis is a sample of fetching the site names and setting to a non-default value\n\n```typescript\nconst sites = await controller.listSites();\nsites.forEach(site =\u003e {\n    if (site.name !== \"default\") {\n        controller.setSite(site.name);\n    }\n})\n```\n\n\n### Authorizing a guest to connect through the hotspot\nThe first parameter is the MAC of the connecting device. This is captured by the hotspot and passed to your portal page in the page redirection.\n\n```typescript\nconst clientMac = \"00:11:22:33:44:55\";\nconst accessPointMac = \"66:77:88:99:aa:bb\";\nconst authResponse = await controller.authorizeGuest(clientMac, accessPointMac);\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foddbit%2Funifi-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foddbit%2Funifi-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foddbit%2Funifi-js/lists"}