Notion and iOS Shortcuts - Add Item To Database using the API

Jon Tormod Nordland
29 Jul 202107:38

Summary

TLDRThis tutorial demonstrates how to use iOS Shortcuts to add items to a Notion database. It guides through creating an API user, obtaining a database ID, and crafting a JSON request to add tasks. The process includes setting up API access, sharing the database with the integration, and using headers for authorization. The video concludes with a practical example of adding a to-do item and suggests using user input for dynamic task addition, encouraging feedback for more content.

Takeaways

  • πŸ“± The video demonstrates how to use iOS Shortcuts to add items to a Notion database.
  • πŸ”‘ It's necessary to create an API user or integration in Notion to get a secret key for authentication.
  • πŸ”— The database must be shared with the API user to make it accessible for API calls.
  • πŸ†” Retrieving the Database ID is crucial, which can be done from the address bar or by copying the page link.
  • πŸ“ The video explains how to make a POST request to the 'pages' endpoint in Notion's API to add a new item.
  • πŸ“ˆ Three headers are required for the API call: Authorization, Notion Version, and Content-Type.
  • πŸ”‘ The Authorization header uses the 'Bearer' keyword followed by the secret key.
  • πŸ“‘ The content of the data being sent is formatted in JSON, specifying the properties of the new database item.
  • πŸ”„ The video shows how to dynamically input the title for the new item using Shortcuts' input feature.
  • πŸ”„ It also illustrates refreshing the Notion database to see the newly added items.
  • πŸŽ₯ The creator encourages feedback and subscriptions for more similar tutorial videos.

Q & A

  • What is the purpose of the iOS Shortcuts demonstration in the video?

    -The purpose of the demonstration is to show how to use iOS Shortcuts to add items to a database in Notion.

  • What is the first step in adding items to a Notion database using iOS Shortcuts?

    -The first step is to create an API user or API integration in Notion by visiting the 'Notion > My integrations' page and following the prompts.

  • What is the name given to the API integration in the video?

    -The API integration is named 'fubar' in the video.

  • Why is a secret key important in this process?

    -The secret key is important as it authenticates the API calls to the Notion database, ensuring secure access.

  • How do you make a Notion database accessible to API calls?

    -You make a database accessible to API calls by sharing it with the integration user that you created earlier.

  • What is the method used to retrieve the database ID in the video?

    -The database ID is retrieved by copying the relevant part of the URL from the address bar or by copying the page link and extracting the necessary part.

  • What does the video demonstrate about making an API call to the Notion database?

    -The video demonstrates how to use the 'Get Content of URL' action in iOS Shortcuts to make a POST request to the 'pages' endpoint with the necessary headers and JSON payload.

  • What are the three headers required for the API call in the video?

    -The three headers required are Authorization (with the Bearer token and secret key), Notion Version, and Content-Type (application/json).

  • What is JSON and why is it used in this context?

    -JSON (JavaScript Object Notation) is a lightweight data-interchange format used here to structure the data payload for the API call to add a new page to the Notion database.

  • How does the video suggest personalizing the Shortcut to add different items to the Notion database?

    -The video suggests using the 'Ask for Input' action in iOS Shortcuts to prompt the user to enter text for the to-do list, which then replaces the static text in the JSON payload.

  • What feedback does the video creator seek from viewers?

    -The video creator seeks feedback on whether viewers are interested in more simple explanations like the one provided and may consider making more videos based on the response.

Outlines

00:00

πŸ“± Automating Notion Database Updates with iOS Shortcuts

The script demonstrates how to use iOS shortcuts to automate adding items to a Notion database. It begins by introducing a simple Notion database with a 'Name' and a 'Checkbox' for task completion. The tutorial assumes the viewer has a Notion account and proceeds to guide through creating an API user and integration for Notion, obtaining a secret key, and ensuring the database is API accessible. It then explains how to get the database ID from the URL and shows the process of making an API call to add a new page to the database using the 'Get Content of URL' action, setting headers with the authorization, Notion version, and content type. The JSON format for the data payload is also discussed.

05:03

πŸ”§ Customizing iOS Shortcuts for Dynamic Notion Database Entries

This paragraph continues the tutorial by showing how to add a new page to the Notion database with custom properties using the iOS Shortcuts app. It details the process of setting the 'text content' for a new entry and suggests ways to avoid adding duplicate items by asking for user input. The script includes steps to prompt the user to input text for the to-do list and replace a static entry with a dynamic variable from the user's input. The tutorial concludes by encouraging viewers to provide feedback and subscribe for more content, highlighting the author's openness to creating more educational videos based on viewer interest.

Mindmap

Keywords

πŸ’‘iOS Shortcuts

iOS Shortcuts are a feature on Apple devices that allow users to automate tasks and create custom actions. In the video's context, Shortcuts are used to interact with the Notion app, specifically to add items to a database without manually entering them. The script demonstrates how to set up a Shortcut to add tasks to a Notion database, showcasing the automation capabilities of iOS.

πŸ’‘Notion

Notion is a productivity app that combines note-taking, database management, and project management features. The video script discusses using Notion to create a database with a simple checkbox for task completion. Notion's API is central to the script's demonstration, as it enables the integration with iOS Shortcuts for automated data entry.

πŸ’‘API User

An API user is a specific account or integration set up for accessing an application's programming interface. In the script, the creator guides viewers on setting up an API user in Notion to facilitate the connection with iOS Shortcuts, emphasizing the need to name the integration and grant it access permissions.

πŸ’‘Secret Key

A secret key is a type of credential used in API integrations to authenticate requests. The script mentions copying the secret key generated after creating the Notion API user, which is essential for securely connecting the iOS Shortcuts with the Notion database.

πŸ’‘Database ID

The Database ID is a unique identifier for a specific database within Notion. The script explains how to obtain this ID from the URL, which is crucial for targeting the correct database when making API calls to add new items via iOS Shortcuts.

πŸ’‘API Calls

API calls are requests made to an application's interface to perform specific actions or retrieve data. The video script details the process of making API calls to Notion's database using the iOS Shortcuts app, which involves setting up headers and data payloads to add new pages or items.

πŸ’‘Headers

In the context of API calls, headers are data structures that provide metadata about the request being made. The script specifies the need for three headers: Authorization, Notion Version, and Content-Type, which are essential for the Notion API to process the incoming request from the iOS Shortcut correctly.

πŸ’‘JSON

JSON, or JavaScript Object Notation, is a lightweight data interchange format often used in APIs for structuring data. The script describes creating a JSON object to specify the properties of the new page to be added to the Notion database, such as the title and checkbox status.

πŸ’‘Magic Variable

In the iOS Shortcuts app, a magic variable is a dynamic element that can be used to store and insert data into the shortcut's workflow. The script uses a magic variable to input the task name provided by the user, making the shortcut more interactive and personalized.

πŸ’‘Content-Type

Content-Type is an HTTP header that indicates the media type of the resource, which is important for the server to parse the request body correctly. In the script, setting the Content-Type header to 'application/json' informs the Notion API that the data being sent is in JSON format.

πŸ’‘Automation

Automation refers to the process of making a system or process operate automatically. The main theme of the video is automating the task of adding items to a Notion database using iOS Shortcuts, which saves time and reduces manual data entry.

Highlights

Demonstration of using iOS Shortcuts to add items to a Notion database.

Introduction of a simple Notion database with a name and a checkbox for task completion.

Explanation of creating an API user or integration in Notion for database access.

Step-by-step guide to naming and setting permissions for the API integration.

Instruction to copy the secret key for use in the Shortcuts app.

Process of sharing the Notion database with the API integration for accessibility.

Method to obtain the database ID from the address bar or share link.

Description of making an API call to the Notion database using the 'get content of URL' action.

Details on setting up headers for the API call, including authorization with the secret key.

Requirement of specifying the Notion version and content type in the API call headers.

Formation of a JSON object to define the structure of the data being sent to the database.

Guidance on how to add a new page to the Notion database with specific properties.

Integration of user input to dynamically add tasks to the Notion database.

Demonstration of the iOS Shortcuts app prompting for input to add unique tasks.

Example of adding a task 'clean the dog' to the Notion database using the shortcut.

Invitation for feedback and suggestions for more tutorial videos.

Note on the lack of subscription and the creator's activity level on the platform.

Transcripts

play00:00

the following is a really simple

play00:02

demonstration

play00:03

of how you can use ios shortcuts

play00:06

to add stuff to your database in notion

play00:11

what i have here let me just show you is

play00:13

a really simple

play00:15

database which just has a name and a

play00:18

checkbox let's call it a checkbox just

play00:22

for fun checkbox

play00:24

that can toggle if a task is done or not

play00:27

do the dishes or whatever

play00:30

like this and what you i want to show is

play00:33

how you can

play00:34

add um items to this database

play00:38

just straight from your ios shortcuts

play00:40

app so

play00:42

let's get to it i'm going to show it all

play00:44

the way from

play00:45

yeah i'm uh i'm not going to show you

play00:47

how to make a notion

play00:49

account i'm guessing you already have

play00:51

that so what you need to do is

play00:52

first you need to create create an ap

play00:55

api user and

play00:57

or api integration

play01:00

you do that by going to this link here

play01:02

notion my integration

play01:04

and it's going to take you to this page

play01:07

you just

play01:08

click on your integration give it a name

play01:10

let's do fubar

play01:12

for instance

play01:15

and give it access to everything here

play01:19

submit and then we're going to get a key

play01:22

secret key here

play01:23

let's just copy that one and bring it

play01:25

over into the

play01:27

shortcuts i'm just going to temporarily

play01:29

store it

play01:31

api key temporarily just store it

play01:34

here like that the second thing we need

play01:37

to do

play01:37

is get a database now let's share

play01:40

the database firstly we need to make the

play01:43

database as

play01:44

accessible to api

play01:47

calls so we do that by go and go into

play01:51

the database

play01:52

let's go here simple to do and then we

play01:55

just

play01:56

share it with we click here and

play02:00

share it with the integration user that

play02:03

we already just created in the foo bar

play02:05

like that invites and don't

play02:08

don't so now this database is callable

play02:11

on callable

play02:12

then the third thing we need to do is

play02:14

get the

play02:15

database id you can get it a couple of

play02:18

ways the

play02:19

simplest i think is to just go up here

play02:21

to the address bar

play02:22

and just grab this part it's the

play02:26

thing going fro so slash all the way up

play02:28

to the first

play02:29

question mark and that's it basically

play02:31

you can also get it by

play02:32

clicking the share and share um

play02:36

uh let's see copy the page link like

play02:39

that and then you're gonna

play02:40

have the link like so

play02:44

and then you just grab this wow this

play02:47

part here let's just remove all the

play02:50

other stuff

play02:51

database id like that

play02:56

okay now we have what we need so

play02:59

now we need to make a call

play03:02

to the uh

play03:05

to the database we do that by using the

play03:08

get content of

play03:09

earl action and then we we need to do

play03:12

the

play03:12

uh call to a specific role

play03:16

and i got that one over here it's

play03:19

called pages we post to the

play03:22

this earl like so

play03:26

and we we do this by we enter

play03:29

this our pages are all so actually we're

play03:33

adding a page

play03:34

and not a database item even though

play03:37

it is in a database we call

play03:41

every item here a page so we are

play03:44

sending a call to pages and we need to

play03:48

add some information to identify

play03:50

and ourself and so we need some headers

play03:53

we need three headers we need first

play03:57

authorization and then we use the

play04:00

bearer oops

play04:03

a bearer space and then the secret key

play04:07

up here

play04:08

like this with no extra spaces that's

play04:10

important

play04:11

and then we need uh notion version

play04:15

like for identifying what

play04:19

ap version we are using

play04:22

just put it in like that and then we

play04:25

need and it wants to know what kind of

play04:27

content

play04:28

we are sending so we're just going to

play04:30

paste in

play04:31

this like so okay

play04:34

so the call is ready but we also need to

play04:36

specify what kind of

play04:39

data we are sending and the content of

play04:41

the data

play04:42

we do that by creating a json if you

play04:45

don't know that json is you need to

play04:47

look that up because i'm not going to

play04:49

explain that here but oops

play04:52

let's grab so this

play04:55

is how you format the json so basically

play04:58

we are tearing

play04:59

the telling that the in the database

play05:03

here and we point to our database id

play05:07

here in this database we're going to add

play05:10

a new page

play05:11

with the properties name

play05:14

which is uh the title uh

play05:18

and the name has a bunch of stuff in it

play05:21

but

play05:21

we're going to set the text content to

play05:24

this lauren ips

play05:26

now we can also blah blah blah

play05:29

whatever like this and then we're joined

play05:33

going to jam this jason into the request

play05:37

like so and we choose file choose magic

play05:40

variable

play05:41

get this text into it so now

play05:45

if we just hit play on this

play05:48

it should work allow it to access the

play05:52

internet

play05:52

like so and we should get a response

play05:55

yeah

play05:55

this means that it worked so

play05:58

i'm just i can just bring up the

play06:02

notion hairs

play06:05

let's see simple

play06:08

to do

play06:09

[Music]

play06:12

let's just refresh it because

play06:16

blah blah blah come through and can run

play06:18

it again to add another

play06:20

like so blah blah blah and again

play06:24

but it's not really helpful to add the

play06:27

same item over over and over

play06:29

so what we do to allow let's

play06:32

get rid of we're just going to ask for

play06:35

input

play06:36

like so what do you

play06:40

want to add to your to-do list

play06:45

like so and then it's going to prompt

play06:47

you from

play06:48

just enter some text and then we just

play06:50

replace this part here

play06:53

with the magic variable

play06:57

from the provided input like so so if we

play06:59

run this again

play07:01

clean that dog like so

play07:08

clean the dog it's in there so that's

play07:11

the simplest way to do it

play07:15

there if you're interested in

play07:18

me making more short simple explanations

play07:20

like this

play07:21

then feel free to comment and

play07:25

subscribe and all of that good stuff

play07:28

not bother with subscription and i'm not

play07:30

that

play07:31

active but give me a feedback if you

play07:34

want more videos like this

play07:36

so okay

Rate This
β˜…
β˜…
β˜…
β˜…
β˜…

5.0 / 5 (0 votes)

Related Tags
NotioniOS ShortcutsAPI IntegrationTask ManagementAutomationDatabaseProductivityTech TutorialWorkflowScripting