How to Call a Serverless Function Or Web API Periodically With iOS Shortcuts
Automate your tasks using the power of shortcuts in iOS

Running a Serverless function or Web API every periodically can be done in so many ways. But today, I want to show you a free option if you have an iPhone or iPad. It is the Shortcut app.
The Shortcut app is available to every iPhone, iPad, or iPod touch running iOS 13.1 and higher. If you donāt own an Apple device, scroll down to the alternative ways to do the same via a different service.
Running Time-Based Actions
I donāt know about you, but I feel the need to run an API or serverless function once a day or an hour every time I work on a side project.
But I donāt particularly appreciate setting up a cron job. Since I run all my applications on Netlify, I donāt have any place to do that.
So I thought, I saw that I could call a Web API via the iOS Shortcuts app. Letās automate that!
My use case
Iām building a dashboard with Angular, Angular Material, Serverless functions, and Upstash (a serverless database for Redis). For that dashboard, Iām using the data from āOur World In Data,ā which is open-source.
Since loading a large amount of data from their repository takes a very long time, I thought letās save that into Redis via Upstash, so the data loads faster.
Updating the information is going to be time-intensive, so my goal is to create a serverless function for Netlify and call it every day with the Shortcuts app.
PS: Iām running that for a few days right now, and itās a total blessing.
For instance, checkout can find my serverless function below, to get an idea of how Iāve created it:
I wonāt dive into the creation of serverless functions in this post, but If you want to learn more about serverless functions and how to build them, check the links below.
How To Automatically Call a Web API Periodically
1. Setup Shortcut
First, letās open the Shortcuts app and tap the + sign to create a new shortcut.

Click on āAdd Actionā and search for āURLā, click it and add the API URL you want to call.

Iāve pasted in a URL to an API. To choose what type of request we want to do, we have to tap on āGet Contents of URLā (if itās not visible on your device, your can search for it in the input field on the bottom).
You can pick GET, POST, PUT, PATCH, and DELETE. If you want, you can send some headers when needed.
In the meantime, try creating the request by pressing the āPlayā button on the bottom.

After making the request, we want to have a notification that tells us when itās done. Tap the bottom input field for searching āShow Notificationā, when found press it.
You can type here anything you like. For this example, Iāve done āReceived Posts URLā. URL is, in this case, the URL weāve set at the top.

Letās test our shortcut by pressing the āPlayā button at the bottom:

Automate shortcut
Now that we demonstrated that our shortcut works, we can automate it to run it daily, weekly, or anything else.
Open the automation tap, which you can find at the bottom of your home screen of the Shortcuts app, and click āCreate Personal Automationā.

Click on the āTime of Dayā and select when you want to run this automation. The choice is yours!

Press āNextā at the top and click āAdd Actionā. Now find the āRun Shortcutā action and press it.

Now we have to select our āCall Web APIā shortcut we made earlier. Press āShortcutā and search for your shortcut and press it.

In my case, this automation will be performed daily at 15:10, which is so awesome!

The best thing about using the Shortcuts app is everything runs locally on my device. Just call āHi Siri, Call Web API,ā and the shortcut will do it!
Github Actions as Alternative For Automating Web API Calls
If you donāt own an Apple device, you canāt use the Shortcuts app. Iām not familiar enough with Android for offering the same functionality, but I think Github Actions is an excellent alternative for automating your Web API or Serverless function call.
Since Github Actions offers so much more than just automating Web API calls, I highly recommend checking the tutorial āRun your Github Actions workflow on a scheduleā by Jason Etcovitch.
Conclusion
There are probably many other ways to automate Web API or Serverless function calls besides using iOS Shortcuts or Github Actions. But the most important is that you use what you find the easiest to use.
For me, doing it on my device for free is very importantāāāthatās why Iāve used the Shortcuts app. If you have other suggestions, please share them. I love to add them to the post as well
Happy coding and automating.
For more Productivity tips with the Shortcuts app, check āAmazing Productivity Shortcuts for Your iPhoneā from Manish Jain
Thanks!
I hope you learned something new or are inspired to create something new after reading this story! š¤ If so, consider subscribing via email (scroll to the top of this page) or follow me here on Hashnode.
Did you know that you can create a Developer blog like this one, yourself? It's entirely for free. šš°šš„³š„
If I left you with questions or something to say as a response, scroll down and type me a message. Please send me a DM on Twitter @DevByRayRay when you want to keep it private. My DM's are always open š






