uptime-kuma-api is a Python wrapper for the Uptime Kuma WebSocket API, currently at version 1.2.1. It provides a programmatic interface for managing monitors and notifications in Uptime Kuma. This library is actively maintained with regular releases, often aligning with new Uptime Kuma versions, and requires Python 3.7 or newer. It was primarily developed to facilitate Uptime Kuma configuration via automation tools like Ansible.
pip install uptime-kuma-apiVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to connect to an Uptime Kuma instance, log in, retrieve existing monitors, and add a new HTTP monitor using a context manager for automatic disconnection. Ensure your Uptime Kuma URL, username, and password are set as environment variables or replaced directly in the script.
Upgrade your Python environment to 3.7+ before upgrading uptime-kuma-api to 1.0.0+.
Ensure your Uptime Kuma server is updated to 1.21.3 or newer when using uptime-kuma-api 1.0.0+. Alternatively, stick to uptime-kuma-api versions <1.0.0 for older Uptime Kuma servers.
Update method calls and parameter names: use `timezoneOption`, replace `wait_timeout` with `timeout`, and use `get_heartbeats()` or `get_important_heartbeats()` instead of the removed `get_heartbeat()`.
Adjust code to expect new return value formats and `Enum` types for relevant attributes. Import and use `Enum` classes (e.g., `MonitorType`) for comparisons.
Always use a `with` statement for `UptimeKumaApi` instances or ensure `api.disconnect()` is called in a `finally` block or at the end of your script.
Ensure your Uptime Kuma instance is running and accessible, authentication is configured, and pass valid credentials to the `UptimeKumaApi` initialization and `login()` call.
First, install the library: `pip install uptime-kuma-api`. Then, use the correct import: `from uptime_kuma_api import UptimeKumaAPI`.
Verify that the `username` and `password` passed to `UptimeKumaAPI(host, username, password)` exactly match a valid user's credentials in your Uptime Kuma instance.
Ensure your Uptime Kuma instance is running and accessible. Verify the `host` parameter includes the correct scheme (e.g., `http://localhost:3001`, `https://your-kuma.com`, or `wss://your-kuma.com/socket.io`) and that no firewall is blocking the connection.
When calling methods like `add_monitor` or `edit_monitor`, ensure all required parameters (e.g., `name`, `type`, `url` for a standard HTTP monitor) are provided with valid values, as specified by the Uptime Kuma API documentation.