Python 3 Script to Make a Currency Converter Using Alpha Vantage API Full Project For Beginners

Python 3 Script to Make a Currency Converter Using Alpha Vantage API Full Project For Beginners


Welcome folks today in this post we will be making a currency converter using alpha vantage api in python. All the source code of the application will be shown below.




Get Started



Now first of all you need to register on the alpha vantage website and go to their official website and get a free api key as illustrated in the below steps







After getting your api key in the above step store it somewhere we will use it in the script


In order to get started you need to create an file and copy paste the following code



# Python program to get the real-time 
# currency exchange rate 

# Function to get real time currency exchange 
def RealTimeCurrencyExchangeRate(from_currency, to_currency, api_key) : 

    # importing required libraries 
    import requests, json 

    # base_url variable store base url 
    base_url = r""

    # main_url variable store complete url 
    main_url = base_url + "&from_currency=" + from_currency + "&to_currency=" + to_currency + "&apikey=" + api_key 

    # get method of requests module 
    # return response object 
    req_ob = requests.get(main_url) 

    # json method return json format 
    # data into python dictionary data type. 
    # result contains list of nested dictionaries 
    result = req_ob.json() 

    print(" Result before parsing the json data :\n", result) 

    print("\n After parsing : \n Realtime Currency Exchange Rate for", 
        result["Realtime Currency Exchange Rate"] 
                ["2. From_Currency Name"], "TO", 
        result["Realtime Currency Exchange Rate"] 
                ["4. To_Currency Name"], "is", 
        result["Realtime Currency Exchange Rate"] 
                ['5. Exchange Rate'], to_currency) 

# Driver code 
if __name__ == "__main__" : 

    # currency code 
    from_currency = "USD"
    to_currency = "INR"

    # enter your api key here 
    api_key = "####apikey###"

    # function calling 
    RealTimeCurrencyExchangeRate(from_currency, to_currency, api_key)


See also  Python 3 Script to Build Domain Name Generator and Checks its Availability Full Project For Beginners


In this python script just replace your api key and run the python app by the below command








As you can see it is showing 1 united states dollar is how much in indian ruppees


Leave a Reply