Skip to main content

Python library for interacting with UniFi Site Manager API

Project description

UniFi Site Manager API Client

Python library for interacting with UniFi’s Site Manager Integration API. Tested on a selfhosted local instance only.

[!NOTE] This library was mainly creted to be used with NetAlertX, as such, full API coverage is not planned. PRs are however more than welcome.

📦 Usage

Navigate to Site Manager ⚙️ Settings -> Control Plane -> Integrations.

  • api_key : You can generate your API key under the Your API Keys section.
  • base_url : You can find your base url in the API Request Format section.
  • version : You can find your version as part of the url in the API Request Format section.
from unifi_sm_api.api import SiteManagerAPI

api = SiteManagerAPI(
    api_key="fakeApiKey1234567890",
    base_url="https://192.168.100.1/proxy/network/integration/",
    version="v1",
    verify_ssl=False
)

sites = api.get_sites()

for site in sites:
    site_id = site["id"]

    unifi_devices = api.get_unifi_devices(site_id=site_id)
    clients = api.get_clients(site_id=site_id)

📘 Endpoints Covered

  • /sites — list available sites
  • /sites/{site_id}/devices — list UniFi devices for a site
  • /sites/{site_id}/clients — list connected clients

🔧 Requirements

  • Python 3.8+
  • requests
  • pytest (for running tests)
  • Local .env file with API credentials

Testing

🌍 Environment Setup

Create a .env file in the project root with the following:

API_KEY=fakeApiKey1234567890
BASE_URL=https://192.168.100.1/proxy/network/integration/
VERSION=v1
VERIFY_SSL=False

🧪 Running Tests

Make sure PYTHONPATH includes the project root, then run:

python3 -m venv venv
source venv/bin/activate
pip install pytest
pip install python-dotenv
cd unifi-sm-api/
pip install -e .
PYTHONPATH=.. pytest -s tests/test_api.py

💙 Donations

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

unifi_sm_api-0.2.2.tar.gz (16.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

unifi_sm_api-0.2.2-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file unifi_sm_api-0.2.2.tar.gz.

File metadata

  • Download URL: unifi_sm_api-0.2.2.tar.gz
  • Upload date:
  • Size: 16.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for unifi_sm_api-0.2.2.tar.gz
Algorithm Hash digest
SHA256 aa69c010c470937bf20a0b41041ac8ecefb077f1910cbfe63cccc9548e08ad5a
MD5 ed1bffed3b62c6610be5806f4b960196
BLAKE2b-256 af9119c08297b7d003565ec65384a60f1c62cabddb6bffcdbe86f72b47a17ab4

See more details on using hashes here.

Provenance

The following attestation bundles were made for unifi_sm_api-0.2.2.tar.gz:

Publisher: python-publish.yml on netalertx/unifi-sm-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file unifi_sm_api-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: unifi_sm_api-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 17.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for unifi_sm_api-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 14b901b110054d66ecbcd755156a3b24f969ac1dadf18a6b1183c0a3380e98ef
MD5 711896310664919401815b5591bdd43d
BLAKE2b-256 c3b7cf7b8fbf5d5cc9ea94626eea1bd13490dce5beda8b5a976461f6d4248651

See more details on using hashes here.

Provenance

The following attestation bundles were made for unifi_sm_api-0.2.2-py3-none-any.whl:

Publisher: python-publish.yml on netalertx/unifi-sm-api

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page