Overview
About 602 words
unifi-cli is a command-line client and terminal UI for the UniFi Network application. Its binary is called unifi, and it does the work you'd otherwise do in the web interface: look at clients and devices, change switch ports, edit networks and firewall policies, and watch the site on a dashboard.
How the commands are built
Every command follows the same grammar:
unifi <subject> <verb> [name] [flags]The subject is a noun (clients, devices, ports, networks, wifi, firewall policies), and the verb says what to do with it. get lists objects or shows one, describe shows every field, and the configuration subjects add create, set, edit, enable, disable and delete. Subjects have verbs of their own where the domain needs them: unifi devices restart, unifi clients block, unifi ports poe.
Four global flags work on every command. --context and --site pick the controller and the site, --output switches between text, wide, json and yaml, and --theme changes the look for one invocation.
What you can do with it
| Task | Start with | Guide |
|---|---|---|
| Sign in to a console or to your UI account | unifi login | Log in |
| Switch between controllers and sites | unifi ctx use, --site | Contexts |
| Find and manage clients | unifi clients get | Clients |
| Operate gateways, switches and access points | unifi devices get | Devices |
| Change switch ports by name | unifi ports get | Switch ports |
| Edit networks, WiFi, firewall, VPN, DNS | unifi networks get | Settings |
| Keep the configuration in git | unifi export, unifi diff, unifi apply | Configuration as code |
| Watch the site | unifi dashboard, unifi topology | Dashboard |
| Read the system log | unifi events get | Events |
| Work like on a switch console | unifi shell | Interactive shell |
What it talks to
A context is either local or cloud. A local context holds an API key created on one console and talks to that console directly on your network. A cloud context holds a Site Manager API key from unifi.ui.com and reaches every console of your UI account through Ubiquiti's cloud connector, from anywhere.
Both end up at the same two API families on the controller. unifi-cli prefers the official Network Integration API and falls back to the controller's internal API for what the official one doesn't cover yet, such as port configuration, events and statistics. API coverage has the full table.
What it does not do
- It manages UniFi Network only. Protect and Access are out of scope for this release; the code has extension points for them, nothing more.
- Administrators are read-only (
unifi users get). Invite and remove them in the web interface. - Signing in with e-mail and password (
unifi login --sso) is experimental and relies on undocumented endpoints. It signs in once, creates a Site Manager API key namedunifi-cli (<hostname>)that is valid for one year unless--key-expirationsays otherwise, and uses only that key afterwards. - The tool was developed against a mock controller and checked read-only against UniFi Network 11.0 on a UCG Ultra. The write paths (port changes,
apply) are verified against the mock only (the sign-in flows, including--sso, were confirmed against the real UI account service), so try a change with--dry-runorunifi difffirst and keep the web interface within reach.
Where to go next
Install the binary, then follow the quick start. If you have no UniFi hardware at hand, the quick start also shows how to run everything against the bundled demo controller.
