FastAPI service that checks host reachability via check-host.net, from any of its worldwide nodes. Supports ping, http, tcp, udp, and dns checks.
api/index.py FastAPI app — all logic in one file
requirements.txt
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
uvicorn api.index:app --reload --port 8000Visit http://localhost:8000/docs for interactive API docs.
GET /api/{check_type}/{country}/{host}
check_type: ping | http | tcp | udp | dns
country: 2-letter code (e.g. "de") or "all" for every node — required, no default
example: /api/ping/de/example.com
GET /api/full/{country}/{host}
Runs all 5 check types in parallel.
example: /api/full/all/example.com
GET /nodes
Lists every available country code, pulled live from check-host.net/nodes/hosts.
GET /{country}/{host}
GET /check/{country}/{host}
Legacy routes, always run a ping check (kept for backward compatibility).
GET /?host=example.com&country=de&type=http
Same as /api/{type}/{country}/{host}, query-string form.
country is required here too — omitting it returns HTTP 400.
- Push this repo to GitHub.
- In Render: New + → Web Service → select the repo.
- Settings:
- Build Command:
pip install -r requirements.txt - Start Command:
uvicorn api.index:app --host 0.0.0.0 --port $PORT
- Build Command:
- No environment variables are required.
- Deploy — Render assigns a public URL automatically.
pip install -r requirements.txt
uvicorn api.index:app --host 0.0.0.0 --port 8000 --workers 2Put it behind Nginx/Caddy if you need HTTPS and a custom domain.
https://github.com/mehdi-hexing/Cloudflare-Scamalytics calls this API's
legacy route (GET /{country}/{host}) directly, hardcoded to
https://check-host.onrender.com. This repo is kept compatible with it:
- Every ping result includes a
ping_msfield (the worker's frontend reads this exact key to show latency per node). - Every error response includes both
detailandmessage(the worker readsmessageto surface a real error to the user instead of a generic "HTTP 502"). - CORS is open (
Access-Control-Allow-Origin: *) since the API is public and read-only.
If you deploy this API under a different URL than
check-host.onrender.com, update CH_RENDER_API_BASE in that worker's
_worker.js accordingly.
- The node list is cached in memory for 6 hours to avoid hitting check-host.net on every request; it refreshes automatically after that.
countryhas no default anywhere — every request must specify one explicitly (or passall).- This code could not be tested live against check-host.net in the
environment it was written in (no network access to that domain), so
response parsing is written defensively with a
rawfallback field. Test against a few real hosts before production use, especially for tcp/udp/dns.