Hasmukh Mistry
4 min readSep 17, 2021

--

Apple Shortcuts – A simple automation to get currency rate

It is always a good idea to simplify your life. I am going to elaborate on the useful notification that I have created using Apple Shortcuts. I will try to keep things simple to not overwhelm you.

Let me align my idea with the set of question and answer models. There is no rocket science to choose this. I like it so I used it.

Aabra ka Dabra!!! Here it goes…

1. How did it all begin?

Before I start with anything I would like to mention how I ended up having an idea like this. I am using wise.com to transfer my money, mostly from EURO to INR.

I keep an eye on the currency difference between the EURO and INR more often. To do this I use this link: https://wise.com/tools/exchange-rate-alerts/?fromCurrency=EUR&toCurrency=INR, And no surprise, I do use the mobile app from wise as well. The habit of checking this currency rate led me to an idea.

I debugged https://wise.com/tools/exchange-rate-alerts/?fromCurrency=EUR&toCurrency=INR and extracted their ENDPOINT which returns a set of different prices in JSON. I did not encounter any problem with this JSON endpoint to fetch using CURL. Yes, you read it right. Just make a request and get the data.

For example:

This leads to an important question.

2. How to use this JSON data effectively?

One might say that there are plenty of ways to take advantage of this JSON data.

I thought of a few which are listed below, let me know in the comments about your ideas too.

  • I could make a cron job for making CURL request and read data. And use some 3rd party service to send a notification. Well, this will need some server or some infrastructure setup. BIG NAAAAAH, It is costly just for the sake of a notification.
  • I could make a mobile app through which I manually make a request and raise a notification. I loved this idea but too much work for one notification. Haha.
  • And a list goes on...

3. How did I end up in Apple Shortcuts?

No surprise, Apple Shortcuts is a wonderful app for some cool automation and scripting. I wanted to get my hands dirty to try apple shortcuts and see what I can learn and achieve.

Let me break down to few steps to summarise what exactly I did.

  • I checked the notification in the scripting section. I wanted to know how exactly this notification works and what is the possibility of passing some data to it. After a few attempts mission was accomplished and I figured out how notification works.
  • Now, As the next step from many, I wanted to fetch JSON data from a wise URL. I found one useful module inside web action, this time it was not in scripting. Again, I made few attempts to use that module to understand the behaviour. Wow, it’s just amazing. No code and things get done.
  • Well well, I made a request and generated a notification. But all were isolated. It was about time to align all together and build something magical.
  • I felt like the scripting section in apple shortcuts is close to python. Mehhh, just my feelings you know. Dictionary, list, loop and some variables, this was all I need.
  • I wrapped all things together and made something beautiful. Not perfect but good enough to serve the purpose.
  • I created automation inside apple shortcuts to run my action AKA fetch-and-notify action at a particular time.
  • I ran my shortcut manually too and… Kaboom, notification received. Instant currency rate directly on my screen as a small handy popup.

4. Alles gut, But how does it look like?

5. What are the steps to add this shortcut to any iPhone?

Click on the following link:

https://www.icloud.com/shortcuts/1d250fed113f42b5bafb15d2cfa12c38

Make sure you Allow Untrusted Shortcuts to be loaded.

6. Digging deeper into each step:

  • Making a request to JSON endpoint using Web component in shortcuts.
  • Saving JSON contents inside rateHistory variable.
  • Looping through rateHistory and extract values.
  • Get the last item from extracted values.
  • Passing the last item into notification as a text.

7. Useful Tweaks:

  • Try changing the JSON endpoint to a different URL in the script from wise.com.
  • Make this shortcut as automation within Apple Shortcuts to receive automated notifications.
  • Add this shortcut to home for easy accessibility.
  • This shortcut is tested in iPhone Xs, It should work in other models too. If not, add your experience in the comments.

--

--

Hasmukh Mistry

Senior Full Stack Software Engineer | Tech Artist | Ex-trivago | Ex-Metro Markets | Author on Medium