Fill a Notion database via iOS home screen shortcuts through the notion API — with the example of a workout tracker
I personally and also the whole team at wild is extensively using Notion and since I got into all kinds of automations recently, it was time to explore the possibilities of connecting Notion to other apps via their API. In this case I wanted to feed a notion database via a direct input on my iOS Home Screen. To demonstrate it, I built a workout tracker, even if I don’t work out a lot… Muscle Tracker was born.
The goal: Document your workout progress, directly from your iOS Home Screen into a Notion database through an iOS Shortcut, in a frictionless and time saving way.
Here’s a quick mockup of how the user journey from going to the gym till adding a new entry to a Notion database will be. Quite straight forward.
Now that you know what the end result will look like, let’s dive into recreating it step by step.
Tutorial
Feel free to either follow it step by step or adapt it to your own needs. The same concept could be adapted to a lot of different use cases! Happy to see other use cases coming to life, let me know what you create!
Part 1: Notion Database
The Database will collect all the data we’re submitting and it will give an overview of your workout progress.
Feel free to duplicate the notion template and continue with Part 2.
Create Notion Database
We want to show the exercise, when we did it and how much weight/time/repeats we did.
- Create a new Notion page and select
Table
and then+ New database
- Add a new entry and create three new properties.
Select
,Date
,Number
- Rename
Select
toExercise
- Keep
Date
as it is - Rename
Number
toUnit
- Add all the different exercises you wanna track to the
Exercise
property. Examples:Treadmill
,Upper Back
,Leg Press
*It’s important to plan the properties in the beginning to avoid tedious changes later. Especially when it comes to property names.
Create Filtered View
For a better overview we will create multiple views with different filters. One view that shows all the entries, with the latest entry on top and others that only show the specific exercises with the latest entry on top.
- Rename the current view to
Latest
- Click
Sort
& selectDate
and thenDescending
- Click
...
next to theLatest
View and duplicate it, keep the sort settings - Rename it to one of the Exercise Tags you created. Example:
Leg Press
- Click
Filter
,Exercise
& selectLeg Press
- Duplicate this view, rename it and filter it by the other exercises you added earlier.
- The Notion Database is ready
Part 2: Notion Integration
We now need to open the door for adding something to a notion database from an outside app.
Create the Notion Integration
What we need is the Internal Integration Token.
- Go to notion.com/my-integrations
- Create a new Integration
- Add a
Name
+ select theAssociated Workspace
(in case you have multiple), leave the rest as it is - Hit
Submit
on the bottom of the page - Copy the
Internal Integration Token
and paste it to your notes, you’ll need it later
Share the database with your integration
What we need is to get the Database ID
- Go back to the notion database you created earlier and click
Share
- You can now share it with the Integration you created
- To get the Database ID, click
Share
and thenCopy link
, paste it to your notes and only keep part between the/
and the?
. See screenshot above.
Note: In case your database is embedded into another page you need to copy the link to the database view in order to get the ID.
Part 3: Apple Shortcuts
In this part we want to make sure that the input we want to track, finds its way to the notion database
Feel free to download a Shortcut Example (Leg Press). Don’t forget to Add your API Key
and your Database ID
Creation Date
We get todays date and convert it into a format that notion can read
- Open the Shortcut app & create a new Shortcut
- Add the
Date
action, you can search for it in the search field in the sidebar - Add the
Format Date
action - Click on
Show more
and selectIso 8601
as a date format.
Add Input
That’s the question and the input field that will pop up when you’re using the iOS Shortcut.
- Add the
Ask for Input
action, this will be the question you get asked when you use the shortcut - Select
Number
as an input type and enter “How much did you lift?” as a prompt
Add json code
I can’t code, so I found a couple of snippets online and adapted them. See sources on the bottom of the article. Make sure everything is named exactly like it is named in the Notion database.
- Add the
Text
action - Paste in the following Json code snippet:
Database ID = The ID you extracted from the database url
Entry Name = Name of the entry. In our case “Leg Press”
Exercise Tag = Tag from the select property. In our case “Leg Press”
Formatted Date = Output from step two, the formatted date
Provided Input = Output from the question we added in the previous stepTo enter Formatted Date & Provided Input just start typing it in and then the options will pop up
Get contents of …
That’s the part where we post something into the notion database via the API.
- Select the
Get contents of …
action and add https://api.notion.com/v1/pages as the URL - Click Show More & select
Post
as a Method - Add 3 Headers
Authorization:Bearer ‘Secret Key
(Key from the notion integration)
Notion-Version:2022–06–28
(You can get the most recent version here)
Content-Type:application/json
- Set Request Body to
File
- Open the
Choose a Variable
dropdown and chooseSelect Magic — Variable
- Click the small
Text icon
below the text action
Test the automation
Click the little play icon on the top right of the window. Moment of truth. 3. 2. 1.
- Click the
Play Icon
in the top bar - Enter a number as an input
- Notion database gets populated with a new entry
- You did it!
If there’s an Error, it’s probably a typo in the json code, it’s important that everything has exactly the same name as it has in Notion.
Part 4: iOS Home Screen & Automation
Create a new Home Screen + add Shortcuts
Let’s dedicate a full home screen to our workout shortcuts so we can fully focus on what’s important in the gym.
- Prepare square thumbnail images and save them to your photos
- Open the Shortcut in the Shortcuts app
- Tap the
Share Icon
- Select
Add to Home Screen
- Select a thumbnail image + Name your Shortcut
- Hit
Add
- Move the Shortcut to an empty Home Screen
- Repeat that with all the Shortcuts you want to add
Bonus: Add a notion widget with your Muscle Tracker to quickly see what your last entries were. See my set up in the screenshot above.
Add new Focus
This will give us the chance to hide all the other apps and only show workout related apps and shortcuts. It suddenly feels like a new phone!
- Go to
Settings
>Focus
- Tap
+
- Tap
Custom
- Add a Name (in this case “Fitness”), Color + Icon and hit
Next
- Go through the other steps and hit
Done
- Go back to the settings of your freshly created Fitness focus and under options tap
Home Screen
- Activate
Custom Pages
+ select the screen you want to have visible during the Fitness Focus - Hit
Done
Bonus: Turn the Focus automatically on when you arrive at a location or when you join a wifi network. I sometimes had issues with it though, probably because my gym is too close to my home. When you have an apple watch, you could also turn it on automatically as soon as you start a workout.
Create Automations to switch your wallpaper
To have a clear visual cut between your default focus and your fitness focus, it helps to automatically change the background as soon as the focus is changed.
Either follow the steps below or watch this great YouTube video from #QuickTips with Jacob.
- Prepare two wallpapers, the one you always use and the one you want to add to your fitness focus. Call them
Regular
andFitness
- Create an album for each background
- Open the Shortcuts app, go to
Automations
and hit the+
- Select
Create Personal Automation
- Scroll down to Focus and select
Fitness
- Keep
When Turning On
selected and tapnext
- Use the following settings:
a. FindAll Photos
whereAlbum
is
Fitness
b. SetLock Screen and Home Screen
wallpaper toPhotos
- Do the same, just with the other background, for
When Turning Off
- Activate your fitness focus and you’re home screen will transform into fitness mode
- Happy lifting!
What I would love to add in the future:
- Show the latest exercise value in the prompt or even in the thumbnail
- Add units like kg or min to the Notion database (not possible right now)
- Find out why starting an automation when connecting to a specific wifi isn’t very reliable
Please let me know if you have more ideas!
Sources:
Change iPhone Wallpaper: #QuickTips with Jacob
Create Json Snipped: Jon Tormod Nordland
Other Example: Quick Add To-Do List
For a simpler Shortcuts to Notion example, check out the Quick-Add To-Do List, that makes it possible to add a task from anywhere, without opening Notion.