fix: change currency exchange API to api.frankfurter.app

This commit is contained in:
dsnetprofitxl
2023-10-03 20:51:28 -04:00
committed by ruthra kumar
parent ff6b38c9e7
commit 76919c4af2

View File

@@ -113,13 +113,12 @@ def get_exchange_rate(from_currency, to_currency, transaction_date=None, args=No
if not value:
import requests
api_url = "https://api.exchangerate.host/convert"
response = requests.get(
api_url, params={"date": transaction_date, "from": from_currency, "to": to_currency}
)
api_url = f"https://api.frankfurter.app/{transaction_date}"
response = requests.get(api_url, params={"from": from_currency, "to": to_currency})
# expire in 6 hours
response.raise_for_status()
value = response.json()["result"]
value = response.json()["rates"][to_currency]
cache.setex(name=key, time=21600, value=flt(value))
return flt(value)
except Exception: