Async Python client for the UniFi Access API
Project description
aiounifiaccess
Async Python client for the UniFi Access API.
- Full REST API coverage — all endpoints from API v4.0.10
- Real-time events — WebSocket listener with auto-reconnect and typed event models
- Webhook support — HMAC-SHA256 signature verification utility
- Pydantic v2 models — fully typed request/response objects
- Async-native — built on aiohttp for composability with other async libraries
Installation
pip install aiounifiaccess
Quick Start
import asyncio
import os
from aiounifiaccess import UniFiAccessClient
async def main():
async with UniFiAccessClient(
host=os.environ["UNIFI_ACCESS_HOST"],
api_token=os.environ["UNIFI_ACCESS_TOKEN"],
) as client:
# List all users
users, pagination = await client.users.list()
for user in users:
print(f"{user.first_name} {user.last_name} ({user.status})")
# Get a specific door
door = await client.doors.get("door-id-here")
print(f"{door.name}: {door.door_lock_relay_status}")
# Remote unlock
await client.doors.unlock("door-id-here", actor_name="API Script")
asyncio.run(main())
Event Listener
import asyncio
import os
from aiounifiaccess import UniFiAccessClient, DoorPositionEvent, DoorUnlockEvent
async def main():
async with UniFiAccessClient(
host=os.environ["UNIFI_ACCESS_HOST"],
api_token=os.environ["UNIFI_ACCESS_TOKEN"],
) as client:
@client.on(DoorPositionEvent)
async def handle_dps(event: DoorPositionEvent):
status = event.data.object.status
door = event.data.location.name
print(f"{door} is now {status}")
@client.on(DoorUnlockEvent)
async def handle_unlock(event: DoorUnlockEvent):
actor = event.data.actor.name
door = event.data.location.name
print(f"{actor} unlocked {door}")
await client.listen()
asyncio.run(main())
Webhook Verification
from aiounifiaccess import verify_webhook_signature
is_valid = verify_webhook_signature(
secret="your_webhook_secret",
signature_header=request.headers["Signature"],
body=await request.read(),
)
API Managers
| Manager | Attribute | Endpoints |
|---|---|---|
| Users | client.users |
29 |
| Visitors | client.visitors |
13 |
| Access Policies | client.access_policies |
15 |
| Credentials | client.credentials |
17 |
| Doors | client.doors |
13 |
| Devices | client.devices |
4 |
| System Logs | client.system_logs |
4 |
| Identity | client.identity |
6 |
| Webhooks | client.webhooks |
4 |
| Server | client.server |
2 |
Compatibility
| Library Version | API Reference Version |
|---|---|
| 0.1.x | 4.0.10 |
Requirements
- Python 3.11+
- aiohttp >= 3.9
- pydantic >= 2.0
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aiounifiaccess-0.1.1.tar.gz.
File metadata
- Download URL: aiounifiaccess-0.1.1.tar.gz
- Upload date:
- Size: 27.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a6333e5c2e75e29fe778e7135d6951ca2ee2c5df12477c554fa464b346d6161
|
|
| MD5 |
02cb1a5dad7aee821b849c9d970259c6
|
|
| BLAKE2b-256 |
6b928192024afe37372e89fec210364e9de5cc944179b92852ebef284b8172b4
|
Provenance
The following attestation bundles were made for aiounifiaccess-0.1.1.tar.gz:
Publisher:
publish.yml on realworldtech/aiounifiaccess
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aiounifiaccess-0.1.1.tar.gz -
Subject digest:
6a6333e5c2e75e29fe778e7135d6951ca2ee2c5df12477c554fa464b346d6161 - Sigstore transparency entry: 1168891201
- Sigstore integration time:
-
Permalink:
realworldtech/aiounifiaccess@a76cc3292f793cb3095e9e15aaff34904bbf1ee4 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/realworldtech
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a76cc3292f793cb3095e9e15aaff34904bbf1ee4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file aiounifiaccess-0.1.1-py3-none-any.whl.
File metadata
- Download URL: aiounifiaccess-0.1.1-py3-none-any.whl
- Upload date:
- Size: 35.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
108c61e9968917c27b65c054518dff54752259feae0654372852dddaf1e5b7d3
|
|
| MD5 |
9431ea49f8415210bc8e051612294879
|
|
| BLAKE2b-256 |
4b8a9a9293c13b7028b4e23ffa0eb55d0baa88448eb05835483078c01550d69f
|
Provenance
The following attestation bundles were made for aiounifiaccess-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on realworldtech/aiounifiaccess
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aiounifiaccess-0.1.1-py3-none-any.whl -
Subject digest:
108c61e9968917c27b65c054518dff54752259feae0654372852dddaf1e5b7d3 - Sigstore transparency entry: 1168891325
- Sigstore integration time:
-
Permalink:
realworldtech/aiounifiaccess@a76cc3292f793cb3095e9e15aaff34904bbf1ee4 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/realworldtech
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a76cc3292f793cb3095e9e15aaff34904bbf1ee4 -
Trigger Event:
push
-
Statement type: