Skip to content

Lightweight Python library for interacting with UniFi’s Site Manager Integration API.

License

Notifications You must be signed in to change notification settings

netalertx/unifi-sm-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Lightweight Python library for interacting with UniFi’s Site Manager Integration API.

Resources

License

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

No packages published

Languages