Skip to content

This is a self hosted, free, open source Python Currency Exchange Rate API fork.

License

Notifications You must be signed in to change notification settings

tim-hub/sanic-currency-exchange-rates-api

Repository files navigation

Sanic Currency Exchange Rates Api

CodeFactor

This is a self hosted, free, currency exchange rate api, free demo at exchange-rate.bai.uno.

The current and historical foreign exchange rates data are from European Central Bank .

Usage

Latest date will be returned, if the date was not in Euro Central Bank history records

Latest & specific date rates

Get the latest foreign exchange rates.

GET /api/latest

Get historical rates for any day since 1999.

GET /api/2018-03-26

Rates are quoted against the Euro by default. Quote against a different currency by setting the base parameter in your request.

GET /api/latest?base=USD

Request specific exchange rates by setting the symbols parameter.

GET /api/latest?symbols=USD,GBP

Rates history

Get historical rates for a time period.

GET /api/history?start_at=2018-01-01&end_at=2018-09-01

Limit results to specific exchange rates to save bandwidth with the symbols parameter.

GET /api/history?start_at=2018-01-01&end_at=2018-09-01&symbols=ILS,JPY

Quote the historical rates against a different currency.

GET /api/history?start_at=2018-01-01&end_at=2018-09-01&base=USD

Client side usage

The primary use case is client side. For instance, with money.js in the browser

let demo = () => {
  let rate = fx(1).from("GBP").to("USD")
  alert("£1 = $" + rate.toFixed(4))
}

fetch('https://api.exchangeratesapi.io/latest')
  .then((resp) => resp.json())
  .then((data) => fx.rates = data.rates)
  .then(demo)

Why we need a new fork

This project is a fork from ExchangeRatesApi project, the original project is great, but as a project, is seems like they have some outdated dependencies (security issues) and difficulties to deploy.

Difference Original Fork
sanic version 0.8.x latest
python 3.6 3.10
pin dependencies false true
deploy to heroku one click not one click yet, but it could be deployed to heroku easily through the docker image
deploy as container got some problem easy
xml parser xml.etree defusedxml

Contributing

License