Notion
Interact with your Notion workspace.
This driver is in beta. Contact us on Slack to use it.
If you are not familiar with Notion, check out their website. It's pretty amazing all-in-workspace.
Find below is their websiteπŸ‘‡
Notion – The all-in-one workspace for your notes, tasks, wikis, and databases.
Notion
Login link
Before anything, you have to connect to your account in Notion, create your integration and make sure it has access to your page or your database.

Step 1: Create an integration.

    Click the "+ New integration" button.
    Give your integration a name - I chose "Vacation Planner".
    Select the workspace where you want to install this integration.
    Click "Submit" to create the integration.
    Copy the "Internal Integration Token" on the next page and save it somewhere secure, e.g. a password manager.
​

Step 2: Share a database with your integration

Integrations don't have access to any pages (or databases) in the workspace at first. A user must share specific pages with an integration in order for those pages to be accessed using the API. This helps keep you and your team's information in Notion secure.
Start from a new or existing page in your workspace. Insert a new database by typing /table and selecting a full page table. Give it a title. I've called mine "Weekend getaway destinations". Click on the Share button and use the selector to find your integration by its name, then click Invite.

Connect

1
from naas_drivers import notion
2
​
3
token = "*********"
4
notion.connect(token)
Copied!

Get database

1
from naas_drivers import notion
2
​
3
token = "*********"
4
database_url = "https://www.notion.so/naas-official/8910d64de001479c8494fbecbf52b525?v=4911d8baa8a5494a86f6215a6b0c95fe"
5
database = notion.connect(token).database.get(database_url)
6
database
Copied!

Create a blank page inside a database

1
from naas_drivers import notion
2
​
3
token = "*********"
4
database_url = "https://www.notion.so/naas-official/8910d64de001479c8494fbecbf52b525?v=4911d8baa8a5494a86f6215a6b0c95fe"
5
​
6
page = notion.connect(token).page.create(parent=database_url, title="Page title")
7
page
Copied!

Update a page inside a database with properties

1
from naas_drivers import notion
2
​
3
token = "*********"
4
page_url = "https://www.notion.so/naas-official/Daily-meeting-04-10-2021-2187d1d0f228491c8ef32de65dea8b1c"
5
​
6
page = notion.connect(token).page.get(page_url)
7
​
8
page.properties.title("Name","Page title")
9
page.properties.rich_text("Text","Ceci est toto")
10
page.properties.number("Number", 42)
11
page.properties.select("Select",["Value1","Value2","Value3"])
12
page.properties.multi_select("Muti Select",["Value1","Value2","Value3"])
13
page.properties.date("Date","2021-10-03T17:01:26") #Follow ISO 8601 format
14
page.properties.people("People", ["d40e767c-d7af-4b18-a86d-55c61f1e39a4"]) #list of ID of users
15
page.properties.checkbox("Checkbox", [("Validated",True), ("Connected",False)])
16
page.properties.url("URL","www.naas.ai")
17
page.properties.email("Email","[email protected]")
18
page.properties.phone_number("Phone number","+33 6 21 83 11 12")
19
​
20
page.update()
21
​
22
​
23
#Not yet supported
24
#page.properties.formula()
25
#page.properties.relation()
26
#page.properties.rollup()
27
#page.properties.files()
Copied!

Create Block inside a page

1
from naas_drivers import notion
2
​
3
token = "*********"
4
page_url = "https://www.notion.so/naas-official/Daily-meeting-04-10-2021-2187d1d0f228491c8ef32de65dea8b1c"
5
​
6
page = notion.connect(token).page.get(page_url)
7
​
8
page.block.add.heading_1("Page title")
9
page.block.add.heading_2("Page title")
10
page.block.add.heading_3("Page title")
11
page.block.add.paragraph("Page title")
12
page.block.add.paragraph("Page that you do")
13
page.block.add.numbered_list_item()
14
page.block.add.to_do()
15
page.block.add.toggle()
16
page.block.add.child_page()
17
page.block.add.child_database()
18
page.block.add.embed()
19
page.block.add.to_do()
20
page.block.add.image()
21
page.block.add.video()
22
page.block.add.pdf()
23
page.block.add.bookmark()
24
​
25
#The order in parathesis will define the order of the block creation.
26
page.update()
Copied!

Get the list of users

1
from naas_drivers import notion
2
​
3
token = "*********"
4
​
5
users = notion.connect(token).users.list()
6
users
Copied!
Discover more usage of the API with Notion official documentation:
Start building with the Notion API
Notion API
​
Last modified 12d ago