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

Config file

~/.config/unifi/config.toml:

host = "https://unifi.example.com"
api_key = "YOUR_KEY"

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.

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 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 all networks

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.1.7.tar.gz (86.2 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.1.7-py3-none-win_amd64.whl (6.0 MB view details)

Uploaded Python 3Windows x86-64

unifi_cli-0.1.7-py3-none-manylinux_2_28_x86_64.whl (6.2 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

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

Uploaded Python 3manylinux: glibc 2.28+ ARM64

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

Uploaded Python 3macOS 11.0+ ARM64

unifi_cli-0.1.7-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.1.7.tar.gz.

File metadata

  • Download URL: unifi_cli-0.1.7.tar.gz
  • Upload date:
  • Size: 86.2 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.1.7.tar.gz
Algorithm Hash digest
SHA256 7b2926fe86c5a2fde9866923359a8bdfd88b670f684808b8e96b573bd2dde011
MD5 d711658c2386b3b31468850ae273bf6f
BLAKE2b-256 e79858a06517f16d29c5a995507a347ba44d4e0713139702cbfce46c830aa6f0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: unifi_cli-0.1.7-py3-none-win_amd64.whl
  • Upload date:
  • Size: 6.0 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.1.7-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 320c285a03b732b80da0fd3fb526affeb41e91ed7a9fe7addb45a9e8d77a9760
MD5 f8eb345f583165eae31553a532482922
BLAKE2b-256 645aec95bba874ceb100646ea5b0ce943aa181dbf66bd4bf397a7ef55333fd21

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for unifi_cli-0.1.7-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4d5a3ceebb8cdaf757baf8bba4b07474d4ff2a746a0954b60c0fec42f9873f3f
MD5 52807e85e136cfdc3a275af65b8e81e8
BLAKE2b-256 e174113d8feedfaf7f663cdc85829745a6856429c81d94701e5c19353de51fae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for unifi_cli-0.1.7-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 52f9ee3e69ad509110eeffe9a894006e7afd6f28a19dad628b40b1fe9b2416d1
MD5 23e46e6c3e4ca839d168a9bbed5d2dd8
BLAKE2b-256 ddb663d9a032de4780f5cf077ec0cc4656419ff5baf989bd114f7b9cef28e3d1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for unifi_cli-0.1.7-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 458f0fe4ee1643797d3d4f13f7a9a7f022b2df8de2fe100a45a324fcb00cecd8
MD5 4649fb969c387021c1f2b7a589e2c242
BLAKE2b-256 d68eeff0c68dea50f8a4a591f04a226a6db907e908837ce43f7467d4b2338902

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for unifi_cli-0.1.7-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 18cd2eb63679a754f06429c1e2ec7bd6cfbcb27a9bcda98bd2522f20bec6de88
MD5 a717fd2868fb8f39b1bfe2bf65bf3ac1
BLAKE2b-256 155ba94f469d5dc6e557de99ea49dbcb334b4a5a4ea472db208f9c0b66a81d65

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