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>
Acknowledgements
- Paulus Schoutsen (balloob) creator of aiohue which most of this code repository is modeled after.
Metadata
Release files for aiounifi 98
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aiounifi-98.tar.gz | 101.6 kB | Without provenance | Details for aiounifi-98.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aiounifi-98-py3-none-any.whl | Python 3 | none | any | Details for aiounifi-98-py3-none-any.whl |
Total release size: 188.3 kB
Release files / aiounifi-98.tar.gz
| Download URL | aiounifi-98.tar.gz |
|---|---|
| Size | 101.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3d8c1b6922c95a25af4883255d01d21737b5f21053bf249f129d115c76cfdc5f
|
|
BLAKE2b-256 checksum How to use checksums |
2f35a88cdc2b28c24219643386eee8597c8f3a43062d5004684eb6a0f0288ecb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.17
|
Release files / aiounifi-98-py3-none-any.whl
| Download URL | aiounifi-98-py3-none-any.whl |
|---|---|
| Size | 86.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0ba4570205e2be0c5749e676eda8dd2f11c928ca07b5c5ade47f248e9a1990b2
|
|
BLAKE2b-256 checksum How to use checksums |
fa1cd752cdf4c641c5556219997c82d55b7df70b43699abb88e9a56008659a5a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.17
|
Security for aiounifi 98
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.