Skip to content

mattdennewitz/forex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

forex-observer

Currency exchange rate API. Scrapes 138 currency pairs from Trading Economics and serves them via a fast JSON API.

Quick Start

# Install dependencies
uv sync

# Fetch latest rates
uv run python scraper.py

# Start server
uv run uvicorn main:app

API

Get all currency pairs

GET /
[
  {"from": "EUR", "to": "USD", "price": 1.16},
  {"from": "GBP", "to": "USD", "price": 1.34},
  {"from": "USD", "to": "JPY", "price": 158.12}
]

Get rates for a base currency

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.

Scraper

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.json

Run on a schedule (e.g., hourly cron) to keep rates fresh.

Docker

docker build -t forex-observer .
docker run -p 8000:8000 forex-observer

Dokku Deployment

Configured for Dokku with:

  • Procfile - web process
  • app.json - hourly cron job to refresh rates
git push dokku main

Stack

About

Quick and dirty FX API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors