From a576ed9f3a96c6e4d240a352c210c4c78ac48c7f Mon Sep 17 00:00:00 2001 From: Lucas Held Date: Tue, 2 May 2023 20:43:52 +0200 Subject: [PATCH] Update README.md --- README.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 44328ff..4836bf6 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ Documentation --- The API Reference is available on [Read the Docs](https://uptime-kuma-api.readthedocs.io). -Examples +Example --- Once you have installed the python package, you can use it to communicate with an Uptime Kuma instance. @@ -49,3 +49,17 @@ At the end, the connection to the API must be disconnected so that the program d ```python >>> api.disconnect() ``` + +With a context manager, the disconnect method is called automatically: + +```python +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" + ) +```