Skip to main content

No project description provided

Project description

UniFi API Client Python Port

A Python port of the Art_of_WiFi/Unifi_API_Client library for interacting with Ubiquiti UniFi controllers.
This project preserves the original PHP functionality via Pythons requests and offers:

  • cURL_style options mirroring the PHP implementation
  • Session management (login/logout)
  • Controller_side backup generation & download
  • Most REST/stat endpoints translated to Python

Note: User_management methods (create/update/delete) are currently non‑functional due to authorization/404 errors. Contributions welcome!


Features

  • Login to UniFi OS & classic controllers
  • Generate and download network backups
  • Mirror PHPs cURL options for timeouts, headers, SSL, etc.
  • All major API/stat endpoints converted
  • CSRF handling for UniFi OS

Dependencies

  • http
  • sys
  • requests
  • From requests.exceptions import Timeout, RequestException
  • time
  • re
  • json
  • urllib.parse
  • http.client
  • logging
  • base64

Example Usage

from client import Client

# Initialize (disable SSL verify if using self‑signed certs)
client = Client(
    user="admin",
    password="secret",
    baseurl="https://your-controller-ip",
    ssl_verify=False
)

# Login
client.login()

# List sites
sites = client.list_sites()
print(sites)

# Generate & download backup
bak = client.generate_backup(days=0)   # returns [{'url': '/dl/backup/XYZ.unf'}]
content = client.download_backup(bak[0]['url'])
with open("backup.unf", "wb") as f:
    f.write(content)

# Logout
client.logout()

Known Issues

  • User management (create/update/delete) as well as some other admin required permissions return 404/unauthorized
  • Some endpoints don't get met

License

  • Same as the original github
  • MIT

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

python_unifi_client-1.3.0.tar.gz (26.0 kB view details)

Uploaded Source

Built Distribution

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

python_unifi_client-1.3.0-py3-none-any.whl (25.4 kB view details)

Uploaded Python 3

File details

Details for the file python_unifi_client-1.3.0.tar.gz.

File metadata

  • Download URL: python_unifi_client-1.3.0.tar.gz
  • Upload date:
  • Size: 26.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for python_unifi_client-1.3.0.tar.gz
Algorithm Hash digest
SHA256 80a2f7bdd9d431757f256faadff5bc67b1a4d2c9a6e2e14c7c1c2b1b54f042d8
MD5 31f181c97a8da1df79cb3bb39eca4bd7
BLAKE2b-256 14342ff9134cfd45e3c898b06d3f9a0b16f9631586c930134b29b2ac9a943eaf

See more details on using hashes here.

File details

Details for the file python_unifi_client-1.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for python_unifi_client-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cf9714693c2aba20b6eb306adfafede2eb320e84ef4a6f7ee45bb79587c76de0
MD5 afe29f162667edf88ca2f0fd0b62f753
BLAKE2b-256 fd2825a21e10767f20ef6f3355b9328cfa31ce2df2d6203bfe3e3fccffcb8e6c

See more details on using hashes here.

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