Skip to main content

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

Metadata

Release files for python-unifi-client 1.3.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for python-unifi-client 1.3.4
File Size Uploaded Provenance Actions
python_unifi_client-1.3.4.tar.gz 26.8 kB Without provenance Details for python_unifi_client-1.3.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for python-unifi-client 1.3.4
File Interpreter ABI Platform Actions
python_unifi_client-1.3.4-py3-none-any.whl Python 3 none any Details for python_unifi_client-1.3.4-py3-none-any.whl

Total release size: 53.0 kB

Release files / python_unifi_client-1.3.4.tar.gz

Download URL python_unifi_client-1.3.4.tar.gz
Size 26.8 kB
Tags Source
SHA-256 checksum
How to use checksums
602b1c21d75f6229502f5603b3e267c4422309a184b49929f5e2207340f75d71
BLAKE2b-256 checksum
How to use checksums
6289a8d92a3dd3a43abab0563f2ee9ca12e43c2e09c96ecc7f38a54fc282d149
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.7

Release files / python_unifi_client-1.3.4-py3-none-any.whl

Download URL python_unifi_client-1.3.4-py3-none-any.whl
Size 26.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dc9ed15f4e749c093800dfaa3a563d7fa9ee0159c5d7f47e83ff846413ecd3b3
BLAKE2b-256 checksum
How to use checksums
563fc97e49fdd6c90ec61cda88f69d92672e4dfd1216554f0da437003c6999bc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.7

Security for python-unifi-client 1.3.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page