| name | notion-api-6-rich-text-formatting |
| description | Sub-skill of notion-api: 6. Rich Text Formatting (+1). |
| version | 1.0.0 |
| category | business |
| type | reference |
| scripts_exempt | true |
6. Rich Text Formatting (+1)
6. Rich Text Formatting
Rich Text Structure:
{"type": "text", "text": {"content": "Plain text"}}
{
"type": "text",
"text": {"content": "Styled text"},
"annotations": {
"bold": True,
"italic": False,
"strikethrough": False,
"underline": False,
"code": False,
"color": "red"
}
}
{
"type": "text",
"text": {
"content": "Click here",
"link": {"url": "https://example.com"}
}
}
{
"type": "mention",
"mention": {
"type": "user",
"user": {"id": "user-id"}
}
}
{
"type": "mention",
"mention": {
"type": "page",
"page": {"id": "page-id"}
}
}
{
"type": "mention",
"mention": {
"type": "date",
"date": {"start": "2025-01-17"}
}
}
{
"type": "equation",
"equation": {"expression": "E = mc^2"}
}
Python - Rich Text Helper:
def create_rich_text(text, bold=False, italic=False, code=False, color="default", link=None):
"""Helper to create rich text objects"""
rt = {
"type": "text",
"text": {"content": text},
"annotations": {
"bold": bold,
"italic": italic,
"strikethrough": False,
"underline": False,
"code": code,
"color": color
}
}
if link:
rt["text"]["link"] = {"url": link}
return rt
paragraph_content = [
create_rich_text("This is "),
create_rich_text("bold", bold=True),
create_rich_text(" and "),
create_rich_text("italic", italic=True),
create_rich_text(" text with a "),
create_rich_text("link", link="https://example.com"),
create_rich_text(".")
]
notion.blocks.children.append(
block_id="page-id",
children=[{
"type": "paragraph",
"paragraph": {"rich_text": paragraph_content}
}]
)
7. Relations and Rollups
Create Related Databases:
projects_db = notion.databases.create(
parent={"type": "page_id", "page_id": "parent-page-id"},
title=[{"type": "text", "text": {"content": "Projects"}}],
properties={
"Name": {"title": {}},
"Status": {
"select": {
"options": [
{"name": "Active", "color": "green"},
{"name": "Completed", "color": "gray"}
]
}
}
}
)
tasks_db = notion.databases.create(
parent={"type": "page_id", "page_id": "parent-page-id"},
title=[{"type": "text", "text": {"content": "Tasks"}}],
properties={
"Name": {"title": {}},
"Status": {
"select": {
"options": [
{"name": "To Do", "color": "gray"},
{"name": "Done", "color": "green"}
]
}
},
"Project": {
: {
: projects_db[],
: {}
}
}
}
)
notion.databases.update(
database_id=projects_db[],
properties={
: {
: {
: ,
: ,
:
}
}
}
)
notion.pages.create(
parent={: tasks_db[]},
properties={
: {: [{: {: }}]},
: {: {: }},
: {: [{: }]}
}
)