Skip to main content

uictlapi

PyPI Coverage Docker MIT license CodeFactor Downloads

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.0.

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:

  1. Open the UniFi Network UI and sign in.
  2. Open DevTools → Network, filter by Fetch/XHR.
  3. Click the screen that does what you want (traffic routes, clients, …).
  4. Pick a request to your controller (often under /proxy/network/...).
  5. 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 PATH to trust a specific CA bundle. --no-verify disables certificate checks and should be limited to a trusted lab network.

  • HTTP authentication sends credentials in plaintext and is disabled by default. When --auth targets an HTTP URL, use --allow-insecure-http only 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:pass or two-line user / 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.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for uictlapi 0.1.4
File Size Uploaded
uictlapi-0.1.4.tar.gz 16.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for uictlapi 0.1.4
File Interpreter ABI Platform
uictlapi-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 26.7 kB

Release files / uictlapi-0.1.4.tar.gz

Download URL uictlapi-0.1.4.tar.gz
Size 16.8 kB
Tags Source
SHA-256 checksum
How to use checksums
69dc102e7c34100c72f7059e695e0954bc352384050cf10052b6b7f217286b65
BLAKE2b-256 checksum
How to use checksums
a211f4833260dac48dc89404ddb02fac4ecce3fb7cf509ee5d6600e451db595e
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

Release files / uictlapi-0.1.4-py3-none-any.whl

Download URL uictlapi-0.1.4-py3-none-any.whl
Size 9.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ac21c562a01e7dd1b702c1901d093127d104251403c438f3f4a3a8c565487b08
BLAKE2b-256 checksum
How to use checksums
8daad9e61cc864a0e1f290e329d2ea7a0b642a420901e63e19568064830a2c59
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

Release history Release notifications | RSS feed

0.2.0

2 release files

0.1.5

2 release files

This release

0.1.4 This release

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page