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.

How to

Make sure docker is installed.

  • git clone https://github.com/tim-hub/sanic-currency-exchange-rates-api
  • run docker docker build -t rate-api . && docker run --name rate-api -t -i -e DATABASE_URL=postgresql://dbuser:[email protected]:5432/dbname rate-api

Why a new frok

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/19.12.2
python 3.6 3.7
pin dependencies false true
deploy to heroku one click (can be too)
deploy as container got some problem easy
xml parser xml.etree defusedxml

Usage

Lates & specific date rates

Get the latest foreign exchange rates.

GET /latest

Get historical rates for any day since 1999.

GET /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 /latest?base=USD

Request specific exchange rates by setting the symbols parameter.

GET /latest?symbols=USD,GBP

Rates history

Get historical rates for a time period.

GET /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 /history?start_at=2018-01-01&end_at=2018-09-01&symbols=ILS,JPY

Quote the historical rates against a different currency.

GET /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)

Contributing

contributing guide

License

MIT

Sanic Currency Exchange Rates API

This is a self hosted, free, currency rate api.

Sanic Currency Exchange Rates API Info

⭐ Stars 18
πŸ”— Homepage exchange-rate.bai.uno
πŸ”— Source Code github.com
πŸ•’ Last Update 5 months ago
πŸ•’ Created 2 years ago
🐞 Open Issues 8
βž— Star-Issue Ratio 2
😎 Author tim-hub