Currency exchange rate API. Scrapes 138 currency pairs from Trading Economics and serves them via a fast JSON API.
# Install dependencies
uv sync
# Fetch latest rates
uv run python scraper.py
# Start server
uv run uvicorn main:appGET /
[
{"from": "EUR", "to": "USD", "price": 1.16},
{"from": "GBP", "to": "USD", "price": 1.34},
{"from": "USD", "to": "JPY", "price": 158.12}
]GET /?base=USD
Returns how much of each currency equals 1 USD:
{
"EUR": 0.86,
"GBP": 0.75,
"JPY": 158.12,
"CNY": 6.97
}Invalid base returns 400.
The scraper fetches data from Trading Economics using browser impersonation to bypass TLS fingerprinting.
uv run python scraper.py
# Saved 138 currency pairs to currencies.jsonRun on a schedule (e.g., hourly cron) to keep rates fresh.
docker build -t forex-observer .
docker run -p 8000:8000 forex-observerConfigured for Dokku with:
Procfile- web processapp.json- hourly cron job to refresh rates
git push dokku main- curl_cffi - HTTP with Chrome TLS fingerprint
- selectolax - Fast HTML parsing
- FastAPI - API server
- uv - Package management