Skip to main content

aiounifi

Asynchronous library to communicate with Unifi Controller

Network API v1, with an API key

Controller.network is a client of the official UniFi Network Integration API, the versioned API under /proxy/network/integration/v1 on the console. It authenticates with an API key made in the console under Network → Integrations, and needs no user, password or login. On consoles joined to a UniFi fabric that is the only option, as those cannot hold local users. The legacy interfaces (controller.clients, controller.devices, ...) are unchanged and still need a local user.

config = Configuration(session, "10.0.0.1", port=443, api_key="...")
network = Controller(config).network

info = await network.get_info()  # {"applicationVersion": "10.6.106"}
await network.assign_site("default")  # short name, display name or UUID

await network.devices.update()  # every page, cached by MAC address
switch = network.devices["70:a7:41:65:c0:ce"]
switch = await network.devices.get_details(switch.device_id)  # adds ports and radios
stats = await network.devices.get_statistics(switch.device_id)
await network.devices.power_cycle_port(switch.device_id, port_idx=3)
await network.devices.restart(switch.device_id)

await network.clients.update()
client = await network.clients.get_by_mac("aa:bb:cc:dd:ee:ff")
await network.clients.authorize_guest_access(client.client_id, time_limit_minutes=60)
await network.clients.unauthorize_guest_access(client.client_id)

The v1 API has no websocket. update() fetches every page of a list and then removes cached items the console no longer returns, signalling DELETED. Clients are the exception: the console lists connected clients only, so one that leaves stays cached, as in the legacy API, and signals CHANGED. network.clients.is_connected(mac) and network.clients.last_seen(mac) tell whether and when it was last listed. Errors are NetworkApiError subclasses that also inherit the legacy types (Unauthorized, Forbidden, ...) and carry the API's structured error fields. A 502 from a console that cannot keep up is retried twice with a short backoff before BadGateway is raised.

Try it from the command line:

aiounifi 10.0.0.1 -p 443 -k <api-key>

Publishing

The GitHub release workflow publishes to PyPI using Trusted Publishing and generates PEP 740 publish attestations for each distribution.

Before the first release with this workflow:

  1. In GitHub, create the pypi environment under repository settings and configure any desired deployment protection rules, such as required reviewers or allowed release tags.
  2. In PyPI's project settings, add a GitHub Actions trusted publisher with owner Kane610, repository aiounifi, workflow pythonpublish.yml, and environment pypi.
  3. Merge this workflow before publishing a GitHub release. After the first successful trusted release, verify the attestations on PyPI's release file details, then revoke the old PyPI API token and remove the PYPI_TOKEN GitHub secret if no other workflow uses it.

See PyPI's attestation documentation for details. These are publish attestations, not build provenance.

Acknowledgements

  • Paulus Schoutsen (balloob) creator of aiohue which most of this code repository is modeled after.

Metadata

Release files for aiounifi 101

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

Source distribution (sdist)

Source distribution for aiounifi 101
File Size Uploaded Provenance Actions
aiounifi-101.tar.gz 110.0 kB With provenance Details for aiounifi-101.tar.gz

Built distribution (wheel)

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

Total release size: 199.1 kB

Release files / aiounifi-101.tar.gz

Download URL aiounifi-101.tar.gz
Size 110.0 kB
Tags Source
SHA-256 checksum
How to use checksums
a3371f16b2074e7217f06f2f9974954c43f96b51bf77a1feab894162bebdb177
BLAKE2b-256 checksum
How to use checksums
ddfa46cb8381ff234207e780e9d2ea9d182db1ecb637db3ea928c5878f6c8cf5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 19, 2026.

Transparency log

Release files / aiounifi-101-py3-none-any.whl

Download URL aiounifi-101-py3-none-any.whl
Size 89.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
176b6d210795d44ee745d8c91eb766222c1e6369e2f1ff39f4785df4121dbd81
BLAKE2b-256 checksum
How to use checksums
dc0da5a70246229b3aa8f8efecddb3ea4aa89464d694683326bb41f7df42586e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 19, 2026.

Transparency log

Security for aiounifi 101

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for aiounifi-101.tar.gz

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 Nov 19, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

101 This release

2 release files Full provenance

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