FastAPI-based semantic/OpenAPI proxy for the Tor Onionoo API.
- GitHub: https://github.com/anoni-net/onionoo-fastapi
- Upstream data source: https://onionoo.torproject.org
- This service does not store Onionoo data, it only forwards requests and transforms responses.
- Primary motivation: Onionoo has a solid spec, but no OpenAPI; this service provides a friendly schema for tooling/AI agents.
Reference spec: Tor Metrics – Onionoo
- Service:
https://onionoo.anoni.net - Swagger UI:
https://onionoo.anoni.net/docs
MIT. See LICENSE.
- Python 3.11+
uv
git clone https://github.com/anoni-net/onionoo-fastapi
cd onionoo-fastapi
uv syncOr if you already have the source:
cd onionoo-fastapi
uv syncfastapi run app.main:app --reload --host 0.0.0.0 --port 8000Note: fastapi run requires FastAPI version 0.110.0 or newer.
OpenAPI docs:
- Swagger UI:
http://localhost:8000/docs - OpenAPI JSON:
http://localhost:8000/openapi.json
Build and run with Docker Compose:
docker compose up -d --buildIf port 8000 is already in use, override host port (example: 8001):
HOST_PORT=8001 docker compose up -d --buildStop:
docker compose downConfiguration via environment variables (example):
ONIONOO_BASE_URL=https://onionoo.torproject.org HOST_PORT=8001 docker compose up -d --buildThis service exposes semantic endpoints under /v1/*:
GET /v1/summaryGET /v1/detailsGET /v1/bandwidthGET /v1/weightsGET /v1/clientsGET /v1/uptime
Plus:
GET /healthz
# Summary (semantic keys; upstream short keys are transformed)
curl -s 'http://localhost:8000/v1/summary?limit=1' | jq .
# Details (supports Onionoo query parameters + details-only `fields`)
curl -s 'http://localhost:8000/v1/details?limit=1&search=moria&fields=nickname,fingerprint' | jq .
# Bandwidth
curl -s 'http://localhost:8000/v1/bandwidth?limit=1&search=moria' | jq .
# Weights (relays only)
curl -s 'http://localhost:8000/v1/weights?limit=1&search=moria' | jq .
# Clients (bridges only)
curl -s 'http://localhost:8000/v1/clients?limit=1' | jq .
# Uptime
curl -s 'http://localhost:8000/v1/uptime?limit=1&search=moria' | jq ./v1/summarytransforms Onionoo short keys:- relay:
n,f,a,r→nickname,fingerprint,addresses,running - bridge:
n,h,r→nickname,hashed_fingerprint,running
- relay:
- For some bridge documents (
/bandwidth,/clients,/uptime), Onionoo uses the key namefingerprinteven though the value is a hashed fingerprint; this API exposes that ashashed_fingerprint.
If the client includes If-Modified-Since, it will be forwarded upstream. If Onionoo replies with 304, this service will reply 304 too.
ONIONOO_BASE_URL(default:https://onionoo.torproject.org)