Get Forex exchange rate email daily with Python and Wayscript

We are going to use simple Python code, FreeForexAPI, and Wayscript service to get an update every day. All for free

If you are interested in keeping updated with the forex exchange rates for your earnings, then you most likely stay updated with an app or a website. Here, we are going to use simple Python code, FreeForexAPI, and the WayScript service to get an update on your email every day. All of the services are free, so, there is no cost involved.

Python code to retrieve Forex rate and get daily email with Wayscript

Wayscript is a web automation platform that lets you create flowcharts with multiple modules like Twitter, Slack, Email, Google Apps, and a lot more. It also lets you run Python code in its Python module. This feature makes it more developer friendly than services like IFTTT. FreeForexAPI is a free service to track the forex exchange rates.

Place the Python and “Send Email” module onto the flowchart. A time trigger is chosen on the top of the flowchart to run the code periodically to email you the rates. You can test the flowchart with the “Run Program” button on the top.

The URL for the API depends on the availability of the forex exchange available on FreeForexAPI. You can check the available forex exchanges here. The Python code uses ‘requests’ and ‘json’ module to call the API URL and parse the JSON response. The code extracts the rate which is used as a reusable variable in the project. The variable is used to place the rate in the email subject or body. Wayscript requires you to set the variables you want to extract onto “outputs”, which can then be used in other modules. We used outputs[‘message’] to use it on the email module.

import requests
import json
url = 'https://www.freeforexapi.com/api/live?pairs=USDNPR'
headers = {"Cache-Control": "no-cache","Pragma": "no-cache"}
r = requests.get(url, headers=headers)
data = json.loads(r.text)
if (data['code'] == 200):
	message = str(data['rates']['USDNPR']['rate'])
outputs['message'] = message

The email module uses the email you’ve set on your WayScipt profile. You can use text and variables on the input fields to get an email on your Inbox.

Python Forex daily email with Wayscript

That’s all you need to get the forex rates to your email daily. Email is an universal option but other options such as pushbullet integration would make it much simpler.

Leave a Reply