Getting Error in the response
Getting error in the response requests. It might be a problem with the base url.
Code:
# the parameters we need are the date, base currency, target currency and quantity to convert.
import requests
date = input("Please enter the date in the format 'yyyy-mm-dd': ")
base = input("Convert from the currency: ")
currency = input("Convert to the currency: ")
quant = float(input("How much do you want to convert: "))
base_url = "https://exchangeratesapi.io/"
url = base_url + "/" + date + "?base=" + base + "&symbols=" + currency
response = requests.get(url)
if (response.ok is False):
print("\nError():".format(response.status_code))
#print(response.json()['error'])
else:
data = response.json()
rate = data['rates'][currency]
result = quant*rate
print("\n{0} {1} is equal to {2} {3}, based upon exchange rates on {4}".format(quant,base,result,currency,data['date']))
Base URL which you are using changes its working and now it asks API keys for fetching any data, also please check their documentation for further course of action
if you want to work same like this you can use "https://api.exchangerate.host" this URL but again check its documentation as not every API has same methods and working but this doesn't need any key or login like which mentioned in this course
Hope this help you out
Mayank