API Health Check
Monitor API endpoints and diagnose connectivity issues.
Instructions
- Accept endpoint URLs from the user. If a single base URL is given, check common paths:
/,/health,/healthz,/api/status,/ping. - For each endpoint, run:
curl -s -o /dev/null -w "HTTP %{http_code} | %{time_total}s | %{size_download}B" -m 10 <URL> - Classify results:
- 🟢 Healthy — 2xx, <1s
- 🟡 Slow — 2xx, >1s
- 🔴 Down — Non-2xx, timeout, or connection refused
- Present summary table:
| Endpoint | Status | Time (ms) | Verdict | |----------|--------|-----------|---------| | /health | 200 | 142 | 🟢 | - For failed endpoints, diagnose:
- DNS resolution:
dig <host> +short - Port connectivity:
nc -zw3 <host> <port> - SSL issues:
curl -vI https://... 2>&1 | grep -i ssl
- DNS resolution:
- For repeated monitoring:
watch -n <interval> curl -s -o /dev/null -w "%{http_code}" <URL>
Security
- Never log or display auth tokens in output — mask as
Bearer **** - Accept custom headers via user input, but redact them in reports
- SSRF prevention: Reject requests to private/internal IPs (
10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,169.254.0.0/16,127.0.0.0/8) unless the user explicitly confirms the target is intentional (e.g., homelab monitoring)
Edge Cases
- Self-signed SSL: Use
curl -konly if user explicitly approves - Redirects: Use
curl -Lto follow; report redirect chain - IPv6: Test both A and AAAA if DNS returns both
- Rate limiting: Space requests with 1s delay if checking many endpoints
Requirements
curl(pre-installed on most systems)- Optional:
dig,ncfor deeper diagnostics - No API keys needed