A wrapper for the Uptime Kuma Socket.IO API
Find a file
2023-05-20 13:10:12 +02:00
docs feat: implement timeouts for all methods (#34) 2023-05-19 13:50:39 +02:00
scripts feat: check for required notification arguments (#36) 2023-05-20 13:10:12 +02:00
tests feat: drop support for Uptime Kuma versions < 1.21.3 2023-05-20 12:43:57 +02:00
uptime_kuma_api feat: check for required notification arguments (#36) 2023-05-20 13:10:12 +02:00
.coveragerc add tests 2022-08-02 23:47:56 +02:00
.gitignore docs: add docstrings and sphinx, readthedocs configuration 2022-12-16 21:43:01 +01:00
.readthedocs.yaml docs: add docstrings and sphinx, readthedocs configuration 2022-12-16 21:43:01 +01:00
CHANGELOG.md bump version to 0.13.0 2023-04-07 21:14:13 +02:00
LICENSE chore: update year 2023-01-17 21:06:18 +01:00
README.md feat: add support for uptime kuma 1.21.3 2023-05-19 13:49:36 +02:00
requirements.txt add support for uptime kuma 1.18.0 2022-09-07 13:03:13 +02:00
run_tests.sh feat: add support for uptime kuma 1.21.3 2023-05-19 13:49:36 +02:00
setup.py feat: drop python 3.6 support 2023-05-02 17:57:32 +02:00

uptime-kuma-api

A wrapper for the Uptime Kuma Socket.IO API

uptime-kuma-api is a Python wrapper for the Uptime Kuma Socket.IO API.

This package was developed to configure Uptime Kuma with Ansible. The Ansible collection can be found at https://github.com/lucasheld/ansible-uptime-kuma.

Python version 3.7+ is required.

Supported Uptime Kuma versions:

uptime-kuma-api Uptime Kuma
1.0.0 1.21.3
0.1.0 - 0.13.0 1.17.0 - 1.21.2

Installation

uptime-kuma-api is available on the Python Package Index (PyPI).

You can install it using pip:

pip install uptime-kuma-api

Documentation

The API Reference is available on Read the Docs.

Example

Once you have installed the python package, you can use it to communicate with an Uptime Kuma instance.

To do so, import UptimeKumaApi from the library and specify the Uptime Kuma server url (e.g. 'http://127.0.0.1:3001'), username and password to initialize the connection.

>>> from uptime_kuma_api import UptimeKumaApi, MonitorType
>>> api = UptimeKumaApi('INSERT_URL')
>>> api.login('INSERT_USERNAME', 'INSERT_PASSWORD')

Now you can call one of the existing methods of the instance. For example create a new monitor:

>>> result = api.add_monitor(type=MonitorType.HTTP, name="Google", url="https://google.com")
>>> print(result)
{'msg': 'Added Successfully.', 'monitorId': 1}

At the end, the connection to the API must be disconnected so that the program does not block.

>>> api.disconnect()

With a context manager, the disconnect method is called automatically:

from uptime_kuma_api import UptimeKumaApi

with UptimeKumaApi('INSERT_URL') as api:
    api.login('INSERT_USERNAME', 'INSERT_PASSWORD')
    api.add_monitor(
        type=MonitorType.HTTP,
        name="Google",
        url="https://google.com"
    )