Python is a very versatile programming language. Python is being used in almost each mainstream technology and one can develop literally any application with it.
Let’s see a Python program to the real-time currency exchange rate. To use this service, one must need the API key, which can be get form here. One can get the list of currency codes from here.
We will be using CURRENCY_EXCHANGE_RATE API ,which can return the realtime exchange rate for any pair of digital currency (e.g., Bitcoin) or physical currency (e.g., USD).
Modules Needed :
requests json
Below is the implementation :
# 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 # 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 = "Your_Api_Key" # function calling RealTimeCurrencyExchangeRate(from_currency, to_currency, api_key) |
Output :
Result before parsing the json data :
{‘Realtime Currency Exchange Rate’: {‘1. From_Currency Code’: ‘USD’, ‘2. From_Currency Name’: ‘United States Dollar’, ‘3. To_Currency Code’: ‘INR’, ‘4. To_Currency Name’: ‘Indian Rupee’, ‘5. Exchange Rate’: ‘71.51500000’, ‘6. Last Refreshed’: ‘2018-12-13 17:40:36’, ‘7. Time Zone’: ‘UTC’}}After parsing :
Realtime Currency Exchange Rate for United States Dollar TO Indian Rupee is 71.51500000 INR
Recommended Posts:
- Python | Real time currency convertor using Tkinter
- Get Bit Coin price in real time using Python
- How to get real-time Mutual Funds Information using Python?
- Application to get live USD/INR rate Using Python
- Currency Converter in Python
- How to format numbers as currency string in JavaScript ?
- Real-Time Edge Detection using OpenCV in Python | Canny edge detection method
- Python | Real time weather detection using Tkinter
- Multiple Color Detection in Real-Time using Python-OpenCV
- Detect Cat Faces in Real-Time using Python-OpenCV
- Python - Displaying real time FPS at which webcam/video file is processed using OpenCV
- numpy.rate() in Python
- GST Rate Finder GUI using Python-Tkinter
- Python VLC MediaPlayer - Setting Play Rate
- Python VLC MediaPlayer - Getting Play Rate
- OpenCV | Real Time Road Lane Detection
- YOLO : You Only Look Once - Real Time Object Detection
- Detect and Recognize Car License Plate from a video in real time
- Pafy - Getting Bit Rate of Stream
- Pafy - Getting Raw Bit Rate of Stream
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

