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. Downlod from here: https://pypi.org/project/unifi-sm-api/

[!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.3.tar.gz (17.8 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.3-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: unifi_sm_api-0.2.3.tar.gz
  • Upload date:
  • Size: 17.8 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.3.tar.gz
Algorithm Hash digest
SHA256 f858cbb8e592f316d9913d198235e5e580c4179fdc92946686f1c80d3a0bba76
MD5 df409435408b1b3298bbf54624ac9777
BLAKE2b-256 06cfc8ed30d77c72b6de1bb569b94c858b9b6b2ef956e4c80cc65756c2e40147

See more details on using hashes here.

Provenance

The following attestation bundles were made for unifi_sm_api-0.2.3.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.3-py3-none-any.whl.

File metadata

  • Download URL: unifi_sm_api-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 17.7 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8d3e2f349258088abac9f2b68d14c77c6e7ef25b3e2ec1e425f3ded049588186
MD5 65d467d40a359f4e6cf5502e71846cd4
BLAKE2b-256 6105434879b5db3f8ccbe51023cfaa5ccbbf89332e7559fbb60e85fc291b54e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for unifi_sm_api-0.2.3-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