Skip to main content

CLI for UniFi Network controller

Project description

unifi-cli

codecov

CLI for UniFi Network controller with an interactive TUI dashboard. Designed for both human operators and AI agents.

Quick start

# Install (pick one)
cargo install unifi-cli        # From source
uvx unifi-cli --help           # Run without installing (via uv)
pip install unifi-cli           # Via pip

# Configure
unifi config init               # Interactive setup (prompts for host + API key)

# Use
unifi clients list              # List connected clients
unifi devices list              # List network devices
unifi tui                       # Interactive dashboard

Generate an API key in your UniFi controller under Settings > API.

Installation

From crates.io

cargo install unifi-cli

From PyPI

pip install unifi-cli
# or run without installing:
uvx unifi-cli clients list

From GitHub releases

Pre-built binaries for Linux (x64, arm64), macOS (x64, arm64), and Windows (x64) on the releases page.

Configuration

Run unifi config init for interactive setup, or configure manually:

Environment variables

export UNIFI_HOST=https://unifi.example.com
export UNIFI_API_KEY=YOUR_KEY
# Optional for lab controllers with self-signed or otherwise invalid TLS certs:
export UNIFI_ACCEPT_INVALID_CERTS=true

Config file

~/.config/unifi/config.toml:

host = "https://unifi.example.com"
api_key = "YOUR_KEY"
# Optional; defaults to false.
accept_invalid_certs = false

Multi-controller profiles

[profiles.home]
host = "https://home.example.com"
api_key = "KEY_1"

[profiles.office]
host = "https://office.example.com"
api_key = "KEY_2"
unifi --profile office clients list
# or: UNIFI_PROFILE=office unifi clients list

CLI flags

unifi --host https://unifi.example.com --api-key YOUR_KEY clients list

Priority: CLI flags > environment variables > config file.

TLS certificates are verified by default. For a local controller with a self-signed certificate, pass --accept-invalid-certs, set UNIFI_ACCEPT_INVALID_CERTS=true, or set accept_invalid_certs = true in the config file. Only use this on trusted networks because it weakens protection for API keys, passwords, session cookies, and stream URLs.

When unifi config init cannot verify the controller's certificate, it offers to trust the controller and saves accept_invalid_certs = true for you.

TUI dashboard

unifi tui                       # Launch interactive dashboard

Real-time dashboard with:

  • Client list with bandwidth, connection info, and signal strength
  • Device overview with status and firmware versions
  • Event feed from the controller
  • Client actions: kick, block/unblock, lock/unlock AP
  • Device actions: restart, upgrade firmware, locate LED
  • Filter clients by name with /

Live port monitor

unifi devices ports aa:bb:cc:dd:ee:ff --live   # Real-time port stats

Commands

Clients

unifi clients list                          # List connected clients
unifi clients list --wired                  # Wired clients only
unifi clients list --wireless --name tasmota  # Filter by type and name
unifi clients list --watch                  # Auto-refresh
unifi clients list --fields name,ssid,ip    # Project specific fields (see `unifi schema`)
unifi clients show aa:bb:cc:dd:ee:ff        # Show client details
unifi clients top                           # Top clients by bandwidth
unifi clients block aa:bb:cc:dd:ee:ff       # Block a client
unifi clients unblock aa:bb:cc:dd:ee:ff     # Unblock a client
unifi clients kick aa:bb:cc:dd:ee:ff        # Disconnect a client
unifi clients set-fixed-ip MAC IP [--name]  # Set DHCP reservation

Devices

unifi devices list                            # List network devices
unifi devices list --watch                    # Auto-refresh
unifi devices show aa:bb:cc:dd:ee:ff          # Show device details
unifi devices ports aa:bb:cc:dd:ee:ff         # Show switch/router ports
unifi devices restart aa:bb:cc:dd:ee:ff       # Restart a device
unifi devices upgrade aa:bb:cc:dd:ee:ff       # Upgrade firmware
unifi devices locate aa:bb:cc:dd:ee:ff        # Blink locate LED
unifi devices locate aa:bb:cc:dd:ee:ff --off  # Stop blinking

Events

unifi events list                           # Recent controller events
unifi events list --limit 50                # Last 50 events

Networks

unifi networks list                         # List all networks
unifi networks                              # Same thing

System

unifi system health                         # Show subsystem health
unifi system info                           # Show controller info

Configuration

unifi config init                           # Interactive setup
unifi config check                          # Verify connectivity and API key

Shell completions

unifi completions zsh --install             # Install zsh completions
unifi completions bash --install            # Install bash completions
unifi completions fish --install            # Install fish completions

Agent-friendly design

unifi-cli is designed to work well with AI agents and automation scripts.

Automatic JSON output

When stdout is not a terminal (piped or redirected), output switches to JSON automatically:

# Human at terminal: formatted table
unifi clients list

# Agent piping output: JSON automatically
data=$(unifi clients list)

# Force JSON mode
unifi --json clients list

Clean stdout/stderr separation

Data goes to stdout. Messages go to stderr. Piping always captures clean data:

unifi clients list > clients.json     # stdout: JSON, stderr: "66 clients"
unifi --quiet clients list            # Suppress stderr messages

Structured mutation responses

unifi --json clients block aa:bb:cc:dd:ee:ff
# {"action": "block", "mac": "AA:BB:CC:DD:EE:FF", "status": "ok"}

Runtime schema introspection

unifi schema    # Dumps all commands, arguments, output fields as JSON

Distinct exit codes

Code Meaning
0 Success
1 General error
2 Configuration error
3 Authentication error (401/403)
4 Not found (404)
5 API error (server error)

Development

make check      # Lint and test
make test       # Run tests
make install    # Build and install

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

unifi_cli-0.3.0.tar.gz (112.9 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

unifi_cli-0.3.0-py3-none-win_amd64.whl (6.1 MB view details)

Uploaded Python 3Windows x86-64

unifi_cli-0.3.0-py3-none-manylinux_2_28_x86_64.whl (6.3 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

unifi_cli-0.3.0-py3-none-manylinux_2_28_aarch64.whl (5.9 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

unifi_cli-0.3.0-py3-none-macosx_11_0_arm64.whl (5.8 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

unifi_cli-0.3.0-py3-none-macosx_10_12_x86_64.whl (6.1 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file unifi_cli-0.3.0.tar.gz.

File metadata

  • Download URL: unifi_cli-0.3.0.tar.gz
  • Upload date:
  • Size: 112.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for unifi_cli-0.3.0.tar.gz
Algorithm Hash digest
SHA256 80bca19fc52d62996f162efe7f61a806beca48b091e82302cf9be330a9130665
MD5 9f8e259c3296f0a2d4c8b84caa0f5313
BLAKE2b-256 74ba3333cfc0565b9c061043e6ddc13a125482ef2cefdd1a3319fda96f575f95

See more details on using hashes here.

File details

Details for the file unifi_cli-0.3.0-py3-none-win_amd64.whl.

File metadata

  • Download URL: unifi_cli-0.3.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 6.1 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for unifi_cli-0.3.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 66e3dce912ddd5c3bd38bc75d89b71c6cef481a97c7f5b1d479821628c3a94a3
MD5 d1c936fdb192d010654895ad25cfcc3d
BLAKE2b-256 301738a1ede02961447d371f5f607d963cc77d50dcc140a9458fcb2111281d49

See more details on using hashes here.

File details

Details for the file unifi_cli-0.3.0-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for unifi_cli-0.3.0-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f9e28061b893b23c0ce35fd214a5ab23f8e263b25d81b105e38df583845b3f77
MD5 911aa747ceb193cef9c8334c3769c4a8
BLAKE2b-256 eadb1d64602bf441a543a53852716c9443fdd6e35a4ba2f42145750a043ef578

See more details on using hashes here.

File details

Details for the file unifi_cli-0.3.0-py3-none-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for unifi_cli-0.3.0-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 065941181c9613da615c5af4d355fb784c57342d939d8fe5299ae2b6558dbe2d
MD5 eddacdc8377b34ea60cf6dfe3263e64b
BLAKE2b-256 b9b149161269101c26a9e208ff385660d9c2347f4bcca67ac142eb676c0e25b5

See more details on using hashes here.

File details

Details for the file unifi_cli-0.3.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for unifi_cli-0.3.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 910ca966236061b135e8125d87c15b7bb9bd720b6c2329ae17778b2623ce330a
MD5 c607126d364a135e714d6b2d24f7ab56
BLAKE2b-256 f7587d9af892e9131276cb708ca17e9649f4873bcee7e5bb292d32014b47bcae

See more details on using hashes here.

File details

Details for the file unifi_cli-0.3.0-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for unifi_cli-0.3.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 d90e477d2497be4b1f007ebce0741f22d98dc7aaa372dcd54e0a9b0dd015c55e
MD5 8ee33ac479807e9d1a46dc11bbed8e59
BLAKE2b-256 5716d0237a83b6001291431afcbf6996df312fd39bba51ebf026e00f4273197c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page