AccessHub Python SDK (accesshub-sdk)
An official, production-ready, asynchronous Python SDK for AccessHub access control software and enterprise external integrations.
Features
- Asynchronous & Fast: Powered by
httpxandasynciofor non-blocking I/O. - Strict Data Validation: Fully typed models built with Pydantic v2.
- Webhook Receiver & Signature Verification: Built-in HMAC SHA-256 signature verification and event routing (
WebhookReceiver). - Domain Service Namespaces:
client.auth: User authentication, token management, profile context.client.tenants: Tenant creation, list, and updates.client.members: Access member management (users, visitors, employees) and credential attachments (RFID, PIN, Face).client.groups: Access groups and door assignment rules.client.devices: Hardware device management, remote door opening (unlock_door), telemetry retrieval.client.access: Manual access evaluation and custom access log entry.client.events: Querying real-time access events with pagination and filters.
- Typed Error Hierarchy: Clear, actionable exceptions (
AuthenticationError,NotFoundError,ForbiddenError,ValidationError,APIError,WebhookSignatureError).
Installation
pip install accesshub-sdk
Or install locally in editable mode:
cd SDKs/accesshub-python-sdk
pip install -e .
Quickstart
1. Basic Client Initialization & Login
import asyncio
from accesshub import AccessHubClient
async def main():
async with AccessHubClient(base_url="http://localhost:8000") as client:
# Authenticate and set Bearer token automatically
token = await client.login(username="admin", password="secure_password")
print(f"Logged in token: {token[:15]}...")
# Get current user profile
user = await client.auth.get_me()
print(f"User: {user.username} (Role: {user.role})")
if __name__ == "__main__":
asyncio.run(main())
2. Receiving & Handling Webhooks
AccessHub can dispatch real-time HTTP POST webhooks for events like member.created, access.granted, or access.denied. The SDK provides a WebhookReceiver to handle HMAC SHA-256 verification and route events:
import asyncio
from accesshub import WebhookReceiver, WebhookEvent
# Initialize receiver with shared secret
receiver = WebhookReceiver(secret="my-tenant-webhook-secret")
@receiver.on("access.granted")
async def handle_access_granted(event: WebhookEvent):
print(f"Access granted for member: {event.data.get('member_name')}")
@receiver.on("member.created")
async def handle_member_created(event: WebhookEvent):
print(f"New member registered: {event.data.get('name')}")
# Process incoming raw HTTP body and headers (e.g., inside FastAPI, Flask, or Aiohttp endpoint)
# event = await receiver.process(raw_body=raw_bytes, headers=request_headers)
FastAPI Integration Example:
from fastapi import FastAPI, Request
from accesshub import WebhookReceiver
app = FastAPI()
receiver = WebhookReceiver(secret="my-tenant-webhook-secret")
@receiver.on("access.granted")
async def on_access(event):
print("Door opened:", event.data)
@app.post("/webhook")
async def webhook_endpoint(request: Request):
raw_body = await request.body()
headers = dict(request.headers)
event = await receiver.process(raw_body=raw_body, headers=headers)
return {"status": "success", "event": event.event}
3. Remote Door Control & Telemetry
import asyncio
from accesshub import AccessHubClient
async def main():
async with AccessHubClient(base_url="http://localhost:8000", token="YOUR_JWT_TOKEN") as client:
devices = await client.devices.list()
if devices:
target = devices[0]
print(f"Unlocking door on device '{target.name}'...")
# Send 3-second pulse door unlock command
result = await client.devices.unlock_door(
device_id=target.id,
door_index=0,
pulse_ms=3000
)
print(f"Unlock command status: {result}")
if __name__ == "__main__":
asyncio.run(main())
Error Handling
All SDK exceptions inherit from AccessHubError:
from accesshub import (
AccessHubClient,
AuthenticationError,
NotFoundError,
ValidationError,
WebhookSignatureError,
)
async with AccessHubClient(base_url="http://localhost:8000") as client:
try:
member = await client.members.get("non-existent-id")
except NotFoundError as err:
print(f"Resource not found (404): {err.message}")
except AuthenticationError:
print("Invalid token or credentials.")
except WebhookSignatureError:
print("Invalid webhook signature header.")
Development & Testing
Run unit & integration tests using pytest:
cd SDKs/accesshub-python-sdk
pytest
License
MIT License - Copyright (c) 2026 AccessHub / Tsuriu Tech.
Metadata
Release files for accesshub-sdk 0.1.0
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 |
|---|---|---|---|---|
| accesshub_sdk-0.1.0.tar.gz | 18.8 kB | Without provenance | Details for accesshub_sdk-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| accesshub_sdk-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for accesshub_sdk-0.1.0-py3-none-any.whl |
Total release size: 40.4 kB
Release files / accesshub_sdk-0.1.0.tar.gz
| Download URL | accesshub_sdk-0.1.0.tar.gz |
|---|---|
| Size | 18.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0e237ccca8e1cf3a6b2cf6372341f684b72c60127205821f565461ef475e5960
|
|
BLAKE2b-256 checksum How to use checksums |
513c6c137308d6d1e32dd4deba9201b46385d1bdf8f5606fa69761a39f4ab4f0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.5
|
Release files / accesshub_sdk-0.1.0-py3-none-any.whl
| Download URL | accesshub_sdk-0.1.0-py3-none-any.whl |
|---|---|
| Size | 21.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
82581bf265ce2d2836f44723416cf9a8363edaecb30c5f3cbde0ea8faaed8099
|
|
BLAKE2b-256 checksum How to use checksums |
885d9c54c9cf35cf5514317069a78abde9c699786c1470f48c2ee73be307c7e6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.5
|
Security for accesshub-sdk 0.1.0
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.