Links

Add numbered list in page

Tags: #notion #list #page #organization #snippet
Author: Florent Ravenel
Last update: 2023-04-30 (Created: 2023-04-30)
Description: This notebook explains how to add a numbered list in a Notion page from a list object using naas_drivers.
References:

Input

Import libraries

from naas_drivers import notion
import naas

Setup Variables

  • list_items: List to add in page
  • notion_token: Notion token shared with your database
  • page_url: Notion page URL or ID
# Inputs
list_items = [
"Task1",
"Task2",
"Task3",
]
# Outputs
notion_token = naas.secret.get("NOTION_TOKEN") or "YOUR_TOKEN"
page_url = "https://www.notion.so/naas-official/Test-93655d0408c14923bcd305dd4599cda9?pvs=4"

Model

Add list in page

page_id = page_url.split("/")[-1].split("?")[0].split("-")[-1]
page = notion.connect(notion_token).page.get(page_id)
for l in list_items:
page.numbered_list_item(l)
page.update()

Output

Display result

print("Numbered list added in your page:", page_url)