uictlapi
Curl-like CLI for the UniFi Controller / UniFi OS Web UI API — with login and CSRF handled for you.
Auth and CSRF come from
requests-unifi-auth. This package is
only the HTTP CLI: any Web UI / proxy URL, any method. It is not a typed UniFi SDK and
does not invent domain commands (routes apply, inventory, multi-controller orchestration).
Live auth/CSRF compatibility against real controllers is tracked in
requests-unifi-auth COMPATIBILITY.md.
Verified with this CLI: uictlapi 0.1.3 against UniFi Network 10.5.67
(GET …/trafficroutes → HTTP 200, 2026-08-24).
See the changelog for release history. Security reports are handled through the security policy.
Installation
pip
pip install uictlapi
Requires requests>=2.32.4 and requests-unifi-auth>=0.2.1.
Docker
docker run --rm akinfold/uictlapi:latest --help
Finding API URLs
UniFi does not publish a stable public catalog of every Web UI path. Copy them from the browser:
- Open the UniFi Network UI and sign in.
- Open DevTools → Network, filter by Fetch/XHR.
- Click the screen that does what you want (traffic routes, clients, …).
- Pick a request to your controller (often under
/proxy/network/...). - Copy the full URL (or path) and reuse it with
uictlapi get|post|….
Paths change between UniFi Network versions; treat DevTools as the source of truth.
Safety
-
Create a dedicated local Admin for automation (not Owner / Super Admin). Prefer the minimum role that can call the endpoints you need.
-
Store credentials in a file with mode
600, not in the shell history:mkdir -p ~/.config/uictlapi printf '%s\n' 'user' 'pass' 'controller.example' > ~/.config/uictlapi/auth chmod 600 ~/.config/uictlapi/auth
-
Prefer an auth file that includes the host[:port] (three-line form or
user:pass@host[:port]). The CLI refuses to send credentials unless the scheme, normalized hostname, and effective port match the request URL exactly. -
TLS certificate verification is enabled by default. Use
--ca-bundle PATHto trust a specific CA bundle.--no-verifydisables certificate checks and should be limited to a trusted lab network. -
HTTP authentication sends credentials in plaintext and is disabled by default. When
--authtargets an HTTP URL, use--allow-insecure-httponly when that risk is intentional. -
Never paste passwords, cookies, or CSRF tokens into issues or chat logs.
Usage
Auth (-a / --auth):
user:pass@host- three-line file —
username,password,host(password may contain:and@) user:passor two-lineuser/pass— host from the request URL (less safe; prefer an explicit host in the file)@/path/to/file— file contains any of the forms above
uictlapi get -a @$HOME/.config/uictlapi/auth \
'https://controller.example/proxy/network/v2/api/site/default/trafficroutes'
# Inline (host in the auth string)
uictlapi get -a 'user:pass@controller.example' \
'https://controller.example/proxy/network/v2/api/site/default/trafficroutes'
# Same via Docker (mount the auth file)
docker run --rm -v "$HOME/.config/uictlapi/auth:/auth:ro" akinfold/uictlapi:latest \
get -a @/auth \
'https://controller.example/proxy/network/v2/api/site/default/trafficroutes'
# POST JSON body (from string or @file)
uictlapi post -a @$HOME/.config/uictlapi/auth \
-j '{"enabled":true}' \
'https://controller.example/proxy/network/v2/api/site/default/some-endpoint'
uictlapi --version
Common flags mirror curl-ish habits: -H / -p / -d / -j / -o / --show-headers /
--status-only / --no-verify / --ca-bundle / --allow-insecure-http / -t. Exit
status 1 on HTTP ≥ 400, 2 on transport errors (including auth origin mismatch).
Releasing
Version lives in pyproject.toml and src/uictlapi/__init__.py. Bump on main first
(GitHub Actions → Bump version, or locally with bump-my-version), then:
git tag vX.Y.Z
git push origin vX.Y.Z
The Publish workflow runs tests, uploads to PyPI, pushes multi-arch Docker images
(X.Y.Z, X.Y, and latest when appropriate), and creates a GitHub Release.
Auto-sync of requests-unifi-auth
The Sync requests-unifi-auth workflow (schedule every 6 hours, or manual
workflow_dispatch) checks PyPI for a newer requests-unifi-auth, raises the
>= floor, bumps this package's patch version, pushes main + tag, and
dispatches Publish on that tag.
License
MIT
Metadata
Release files for uictlapi 0.1.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| uictlapi-0.1.5.tar.gz | 24.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| uictlapi-0.1.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 33.8 kB
Release files / uictlapi-0.1.5.tar.gz
| Download URL | uictlapi-0.1.5.tar.gz |
|---|---|
| Size | 24.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
97f8cbaa06c52ec342f08351d2f88f49cd9bfd7e0e18bde662c7440aa8107181
|
|
BLAKE2b-256 checksum How to use checksums |
5529bd056873c68a142fb0e27ff1fcafd6e92390d6d6447e307c8a4c85396b06
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 13, 2026.
Transparency logRelease files / uictlapi-0.1.5-py3-none-any.whl
| Download URL | uictlapi-0.1.5-py3-none-any.whl |
|---|---|
| Size | 9.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
696bcb7b0488443e6b9e66319f65773f273511397e9fdec2835714a140909b6f
|
|
BLAKE2b-256 checksum How to use checksums |
fb98e340406329be7074e59092ee0e4b9b1dc01c76db63783cee03c9d22adb7c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 13, 2026.
Transparency log