An app with selectable API's for checking exchange rates and optional automatic notifications using different backends, built with Go.
- Multiple exchange rate API support (ExchangeRate-API, Open Exchange Rates)
- Rate limiting and request tracking
- Simple HTTP API
- Containerized with Podman (rootless, no daemon)
- State persistence between restarts
- Go 1.16+
- Podman, optionally with
podman-compose(see PODMAN_USAGE.md) - API keys for the desired exchange rate providers
Copy .env.example to .env and fill in your keys:
cp .env.example .env# ExchangeRate-API (er-a) - Get your key from https://www.exchangerate-api.com/
EXCHANGERATE_API_KEY=your_api_key_here
# Open Exchange Rates (oer) - Get your key from https://openexchangerates.org/
OPENEXCHANGERATES_APP_ID=your_app_id_here
# API_STATE_FILE is container-only (it points the app at the mounted /data dir).
# Don't put it in .env — this file is also loaded for local `go run .`, where it
# would override the working-dir default (api_state.json). Pass it via
# `-e API_STATE_FILE=/data/api_state.json`, or set it in compose.yaml.-
Copy
.env.exampleto.envand fill in your API keys (see below) -
Run the application:
# Using Go (writes state to ./api_state.json in the current directory) go run . # Using Podman (state persists to ./data/api_state.json via the mount) podman run --userns=keep-id --user "$(id -u):$(id -g)" \ -e API_STATE_FILE=/data/api_state.json --env-file .env \ -p 8080:8080 -v ./data:/data:Z localhost/exchange-go-notifier:dev # Or using Podman Compose (reads keys from .env) mkdir -p data env UID=$(id -u) GID=$(id -g) podman-compose up
In a container the app writes its state to
/data/api_state.json. Create the./datadir first (mkdir -p data— Podman doesn't auto-create bind mounts); the app creates the state file on first request. To seed zero counters instead:cp api_state.example.json data/api_state.json
The server will start on http://localhost:8080
GET /exchange-rates?api={provider}&base={currency}provider(required): The API provider to use (er-aoroer)
# Using curl
curl "http://localhost:8080/exchange-rates?api=er-a&base=USD"
# Using httpie
http ":8080/exchange-rates" api==er-a base==USD{
"rates": {
"EUR": 0.92,
"GBP": 0.79,
"JPY": 156.42,
"USD": 1.0
}
}| Provider | ID | Request Limit | Documentation |
|---|---|---|---|
| ExchangeRate-API | er-a |
1,500/month | docs |
| Open Exchange Rates | oer |
1,000/month | docs |
go test -vpodman build -t localhost/exchange-go-notifier:dev .
mkdir -p data
podman run --userns=keep-id --user "$(id -u):$(id -g)" \
-e API_STATE_FILE=/data/api_state.json --env-file .env \
-p 8080:8080 -v ./data:/data:Z localhost/exchange-go-notifier:dev--user keeps the state file owned by you; see PODMAN_USAGE.md
for the full setup, including running without --user.
This project is licensed under the Apache 2.0 License - see the LICENSE file for details.