If you deploy your own APIs — on a VPS, a small cloud instance, wherever — you usually find out they're down the same way: a user complains, or you happen to check. Paid monitoring services solve this, but they're overkill (and a recurring cost) for a handful of personal or freelance-scale endpoints.
A CLI tool that watches your endpoints and tells you the moment something breaks — no dashboard to babysit, no subscription:
- Register any number of endpoints, each on its own ping interval
- Concurrent monitoring — endpoints are checked independently, one slow/timing-out endpoint never blocks the others
- Real-time Telegram alerts — down and recovery notifications, sent to one or multiple recipients
- SLA reporting — uptime %, average response time, and a response-time trend, over any time window
- ➕ Endpoint Management —
add/list/removeregistered endpoints, stored in SQLite - ⚡ Concurrent Monitoring Loop — thread-based scheduler, each endpoint pinged on its own interval without blocking others
- 🟢🔴 Up/Down Detection — classifies every check, tracks state transitions
- 📲 Telegram Alerts — instant down alerts and recovery alerts (with downtime duration), sent via a dedicated bot
- 👥 Multi-Recipient Support — alert more than one chat/person; one failed delivery doesn't block the others
- 📊 SLA Reports — uptime %, total checks, downtime count, average response time, longest down streak, over any
--lastwindow - 📈 Response Time Trend — flags endpoints getting slower or faster over the report window, color-coded
- 🛡️ Fails Safe — a broken Telegram config or a failed alert never crashes the monitoring loop
| Layer | Tool | Purpose |
|---|---|---|
| CLI Framework | Typer | Command parsing, options, help text |
| HTTP | Requests | Pinging endpoints, calling the Telegram Bot API |
| Concurrency | ThreadPoolExecutor | Independent per-endpoint scheduling (I/O-bound, thread-based) |
| Storage | SQLite | Endpoint registry + full check history |
| Alerts | Telegram Bot API | Down/recovery notifications |
| Config | python-dotenv | Bot token + chat ID(s) from .env, never hardcoded |
| Terminal UI | Rich | Color-coded tables for lists and reports |
| Testing | pytest | 55 tests — storage, monitor, alerts, and report logic, all HTTP mocked |
apiwatch add --url "https://api.example.com/health" --interval 5m
apiwatch list
apiwatch remove --url "https://api.example.com/health"--interval accepts s / m / h (e.g. 30s, 5m, 1h).
apiwatch startRuns until stopped with Ctrl+C. Pings every registered endpoint on its own schedule, prints live status, and sends Telegram alerts on every up→down or down→up transition (if Telegram is configured).
apiwatch report --last 7d
apiwatch report --last 24hShows, per endpoint: uptime %, total checks, down count, average response time, longest down streak, and a trend indicator.
- Message @BotFather on Telegram, send
/newbot, follow the prompts — you'll get a bot token. - Message your new bot anything (e.g. "hi") so Telegram registers a chat with it.
- Visit
https://api.telegram.org/bot<YOUR_TOKEN>/getUpdatesin a browser — find"chat":{"id":...}in the response. That number is your chat ID. - Copy
.env.exampleto.envand fill in:
TELEGRAM_BOT_TOKEN=your-bot-token-here
TELEGRAM_CHAT_ID=your-chat-id-hereFor multiple recipients, use a comma-separated list:
TELEGRAM_CHAT_ID=123456789,987654321If Telegram isn't configured, apiwatch start still monitors and prints to the terminal — alerts are simply skipped with a warning.
apiwatch/
├── apiwatch/
│ ├── cli.py # Typer app — add/list/remove/start/report
│ ├── monitor.py # concurrent ping loop + state-change detection
│ ├── storage/ # SQLite: endpoint registry + check history
│ ├── alerts/ # Telegram integration
│ ├── report.py # SLA calculation + trend detection
│ └── config.py # loads .env (bot token, chat IDs)
├── tests/ # 55 tests
├── .env.example # template — copy to .env
└── pyproject.toml
git clone https://github.com/rizalcodes/apiwatch.git
cd apiwatch
python -m venv venv
# Windows:
venv\Scripts\activate
# macOS/Linux:
source venv/bin/activate
pip install -e .
cp .env.example .env # then fill in your Telegram bot token + chat IDapiwatch add --url "https://your-api.com/health" --interval 5m
apiwatch startpip install -e ".[dev]"
pytestRizal
Built with Typer, threading, and the Telegram Bot API — because finding out your API is down should never come from a client's message first.