Uptime-Kuma-API
Docker app from jmztaylor's Repository
A REST API wrapper for Uptime Kuma using Uptime-Kuma-API
Overview
Readme
View on GitHubUptime-Kuma-Web-API
A REST API wrapper for Uptime Kuma, built with FastAPI on top of uptime-kuma-api.
Compatibility
| Component | Supported versions |
|---|---|
| Uptime Kuma | 1.21.3 – 1.23.x |
| Python | 3.11+ |
CI runs the end-to-end tests against Uptime Kuma 1.21.3, 1.23.2 and the latest 1.x release. Uptime Kuma 2.x is not supported: uptime-kuma-api has no release for it.
Features
- Monitors, tags, status pages and incidents, maintenances, notifications, proxies and docker hosts
- Uptime, average ping, certificate and server info
- JWT authentication with a small SQLite user database; user management is admin only
- One shared, self-reconnecting connection to Uptime Kuma
- Interactive Swagger docs at
/docs, liveness probe at/health - Docker image for amd64 and arm64: medaziz11/uptimekuma_restapi
Quick start
Create a .env file (see .env.dist):
KUMA_USERNAME=your-kuma-user
KUMA_PASSWORD=your-kuma-password
ADMIN_PASSWORD=choose-a-strong-password
and a docker-compose.yml:
services:
kuma:
container_name: uptime-kuma
image: louislam/uptime-kuma:1
ports:
- "3001:3001"
restart: always
volumes:
- uptime-kuma:/app/data
api:
container_name: backend
image: medaziz11/uptimekuma_restapi
volumes:
- api:/db
restart: always
environment:
- KUMA_SERVER=http://kuma:3001
- KUMA_USERNAME=${KUMA_USERNAME}
- KUMA_PASSWORD=${KUMA_PASSWORD}
- ADMIN_PASSWORD=${ADMIN_PASSWORD}
depends_on:
- kuma
ports:
- "8000:8000"
volumes:
uptime-kuma:
api:
Start it with docker compose up -d. On a fresh Uptime Kuma, open http://localhost:3001 once to
create the Kuma user named in .env. The API connects to Uptime Kuma on the first request, so no
restart is needed afterwards.
Then open http://localhost:8000/docs and log in as admin with your ADMIN_PASSWORD.
Image tags
| Tag | Content |
|---|---|
latest |
the latest release |
v2.0.0, v2.0, v2 |
a specific release / line |
edge |
the tip of main |
dev |
the tip of develop |
Configuration
| Variable | Required | Default | Description |
|---|---|---|---|
KUMA_SERVER |
yes | URL of the Uptime Kuma instance, e.g. https://uptime.example.com |
|
KUMA_USERNAME |
yes | Uptime Kuma user | |
KUMA_PASSWORD |
yes | Uptime Kuma password | |
ADMIN_PASSWORD |
yes | Password of the API admin user. Changing it updates the user at startup. |
|
SECRET_KEY |
no | generated | JWT signing key. When unset, one is generated and stored next to the database. |
ACCESS_TOKEN_EXPIRATION |
no | 11520 (8 days) |
Access token lifetime, in minutes |
KUMA_TIMEOUT |
no | 10 |
Seconds to wait for Uptime Kuma to answer |
KUMA_SSL_VERIFY |
no | true |
Set to false to accept a self-signed Uptime Kuma certificate |
BACKEND_CORS_ORIGINS |
no | [] |
JSON list of origins allowed by CORS |
DB_PATH |
no | db/db.sqlite3 |
SQLite file holding the API users (/db/db.sqlite3 in the Docker image) |
LOG_LEVEL |
no | INFO |
Log level |
The Uptime Kuma account must not have two-factor authentication enabled.
Authentication
TOKEN=$(curl -s -X POST \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data 'username=admin&password=<ADMIN_PASSWORD>' \
http://127.0.0.1:8000/login/access-token | jq -r ".access_token")
curl -H "Authorization: Bearer ${TOKEN}" http://127.0.0.1:8000/monitors
Every endpoint except /login/access-token, /health and the docs requires a token.
The admin user can create, list and delete other users (/users). Other users have full access to
the Uptime Kuma endpoints but cannot manage users.
Endpoints
| Prefix | Operations |
|---|---|
/monitors |
list, get, create, update, delete, pause, resume, heartbeats, add/remove tag |
/tags |
list, get, create, update, delete |
/statuspages |
list, get, create, save, delete, post/unpin incident |
/maintenance |
list, get, create, update, delete, pause, resume, get/set monitors |
/notifications |
list, get, create, update, delete, test |
/proxies |
list, get, create, update, delete |
/docker_hosts |
list, get, create, update, delete, test |
/users |
create, list, get, delete (admin), /users/me |
/info, /uptime, /ping, /cert_info |
read-only server and monitor statistics |
/database |
size, shrink |
/settings |
import a backup |
The full, always up-to-date reference is the Swagger UI at /docs (OpenAPI schema at /openapi.json).
Errors
Errors are returned as {"detail": "..."}.
| Status | Meaning |
|---|---|
| 400 | Uptime Kuma rejected the request |
| 401 | Missing, invalid or expired token; wrong username or password |
| 403 | Admin privileges required |
| 404 | The monitor, tag, status page... does not exist |
| 422 | Invalid request body or parameters |
| 503 | Uptime Kuma is unreachable or refused the configured credentials |
| 504 | Uptime Kuma did not answer in time |
Development
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements-dev.txt
make run # uvicorn with auto-reload (reads .env)
make lint # ruff
make test # unit and integration tests, no Uptime Kuma needed
make coverage # same, with the coverage report
make e2e # end-to-end tests against a real Uptime Kuma in Docker
make up # full stack with docker compose
See CONTRIBUTING.md for the project layout, how to add an endpoint and how to release, and SECURITY.md for reporting vulnerabilities and deployment notes.
Upgrading from 1.x
2.0 has breaking changes. Read the 2.0.0 release notes for the upgrade steps; the changelog has the full list.
License
Categories
Download Statistics
Total Downloads Over Time
Related apps
Explore more like this
Explore allLinks
Details
medaziz11/uptimekuma_restapiRuntime arguments
- Web UI
http://[IP]:[PORT:8000]/- Network
bridge- Shell
sh- Privileged
- false
Template configuration
- Value
- https://[SERVER_IP]:3001
- Target
- /db
- Value
- /mnt/user/appdata/uptime_kuma_api
- Target
- 8000
- Value
- 8000