Skip to main content

CLI for UniFi Network controller

Project description

unifi-cli

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.4.tar.gz (72.5 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.4-py3-none-win_amd64.whl (5.6 MB view details)

Uploaded Python 3Windows x86-64

unifi_cli-0.1.4-py3-none-manylinux_2_28_x86_64.whl (5.8 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

unifi_cli-0.1.4-py3-none-manylinux_2_28_aarch64.whl (5.5 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

unifi_cli-0.1.4-py3-none-macosx_11_0_arm64.whl (5.4 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

unifi_cli-0.1.4-py3-none-macosx_10_12_x86_64.whl (5.7 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: unifi_cli-0.1.4.tar.gz
  • Upload date:
  • Size: 72.5 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.4.tar.gz
Algorithm Hash digest
SHA256 c70bfb17219579e96c8e3fd38cef642a741d3e20d32f684cfc23828b2292850c
MD5 5f866ce91a1031bf04bd94817840324b
BLAKE2b-256 b030d5dc9be90c2dadea6c1ef0af65de11de6b29030477cfa97c488128f1d249

See more details on using hashes here.

File details

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

File metadata

  • Download URL: unifi_cli-0.1.4-py3-none-win_amd64.whl
  • Upload date:
  • Size: 5.6 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.4-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 c72fae2a044e6da41e2fa8942d226a7dfc12ce81ac411a4cf2c8c819b13511f5
MD5 d4e43c1b34f0185cfe3ae9c0c118ff4e
BLAKE2b-256 6d5db67392c9a5bd6d85576cf99aae23d82e5fd734f066b5514892b6c86f6179

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for unifi_cli-0.1.4-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 eedae0405ea35dc862b3ab09b23a51cee3f3eed5353c8f8440d29d6cf50277a1
MD5 fb2f69359fe262e5b51ef63616a979c6
BLAKE2b-256 ffc6add920b211838fe4c565e1eb09ab0ab57ff9797bb7318b2491f536c33661

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for unifi_cli-0.1.4-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 294e96462a9905dec157b51f1d1b9788000fdb7f7a169b11214ccc2b53808c4b
MD5 4573941740a17bec0fcdc26e35d4b354
BLAKE2b-256 78def78c360220242f7f708c2f43ff78e44c2972cdb1924d7ea9dcb350b112d7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for unifi_cli-0.1.4-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b3ee66fb06ef0e8b5f12f698c689fcb499a992e429a94879a2e62e10ca562f0e
MD5 a0aae821ce482bdcea5d47b781a61bcf
BLAKE2b-256 0f79185f6ae08db009140d0ecdb72e316f6afe44bb1a4a2d912b14923189db97

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for unifi_cli-0.1.4-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 42151c5b523cbe498c4185d37be491b3c5a2ac49b5f6db44fa5820a80e03aae4
MD5 2e93f07cc76942e1fa4d6eb61dbde4e8
BLAKE2b-256 80ffa662d732bd91850b212d9c718e49b1cbc7d39392da5c8b58c8ea06a5b214

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