Last answered:

14 Mar 2023

Posted on:

08 Apr 2022


Getting Error in the response

Getting error in the response requests. It might be a problem with the base url.

# 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 = ""

url = base_url + "/" + date + "?base=" + base + "&symbols=" + currency

response = requests.get(url)

if (response.ok is False):

  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']))

1 answers ( 0 marked as helpful)
Super learner
This user is a Super Learner. To become a Super Learner, you need to reach Level 8.
Posted on:

14 Mar 2023


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 ""  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


Submit an answer