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:

cd unifi-sm-api/tests
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.1.tar.gz (15.6 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.1-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for unifi_sm_api-0.2.1.tar.gz
Algorithm Hash digest
SHA256 4b1b9d0ad30244cf93050f38e7208c0ed68407a788cf811acf206af2e12de1bc
MD5 17d80547850222c28479d155d81c9ce9
BLAKE2b-256 7cae340d531d82fda516514f8a05695f98bdf9cdfa801070562464ce00e8c02f

See more details on using hashes here.

Provenance

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

Publisher: python-publish.yml on jokob-sk/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.1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for unifi_sm_api-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5c45669140e125051c5af48f88e1fd504a1487f8ad3790b71d6e4bbdd59698d6
MD5 c1e84a0fa74e3ddb28fef05ffb81b566
BLAKE2b-256 a4bf0de2a29a9b867d1f0bf7d64815d0ace204f501487c56c0ded05984c85b0f

See more details on using hashes here.

Provenance

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

Publisher: python-publish.yml on jokob-sk/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