Notion API bindings.
Setup — set notion.token in context: an internal integration
secret (ntn_... / secret_...) from notion.so/my-integrations, with
the target pages/databases shared with the integration. Comments need
the integration's comment capabilities; ::notion::users needs a
user-information capability (users/me works with any level).
Per-call credentials. Every API-calling function takes an optional
trailing opts Map (token, api-version, base-url). See
::notion::api.
Quick start
::pages ::notion::pages
::databases ::notion::databases
parent-page-id "59833787-2cf9-4fdf-8782-e53db20768a5"
db-id "d9824bdc-8445-4327-be8b-5b47500af6ce"
page ::pages/create-page(parent-page-id, "Meeting notes 2026-07-09", [
::notion/paragraph("Attendees: Curt, Ada."),
::notion/heading(2, "Decisions"),
::notion/bullet("Ship the sql package")
])
rows ::databases/query-database(db-id, {
filter: {property: "Status", status: {equals: "In progress"}}
})
Values
BASE_URL
BASE_URL: Str "https://api.notion.com/v1"
NOTION_VERSION
NOTION_VERSION: Str "2022-06-28"
Functions
bullet
fn (text: Str): Map
A bulleted list item block from plain text.
Example
::notion/bullet("Ship it").type // "bulleted_list_item"
heading
fn (level: Int, text: Str): Map
A heading block: level 1, 2, or 3.
Example
::notion/heading(2, "Decisions").type // "heading_2"
paragraph
fn (text: Str): Map
A paragraph block from plain text.
Example
::notion/paragraph("Hello").paragraph.rich_text[0].text.content // "Hello"
plain-text
fn (rich: Vec): Str
Extract the plain text from a rich-text array (the inverse of
rich-text) — handy when reading pages and blocks.
Example
::notion/plain-text(::notion/rich-text("Hello")) // "Hello"
::notion/plain-text([{plain_text: "Hi "}, {plain_text: "there"}]) // "Hi there"
rich-text
fn (text: Str): Vec
Wrap plain text as a Notion rich-text array (the shape every text-bearing property and block wants).
Example
::notion/rich-text("Hello") // [{type: "text", text: {content: "Hello"}}]
to-do
fn (text: Str): Map
fn (text: Str, checked: Bool): Map
A to-do block from plain text (unchecked by default).
Example
::notion/to-do("Ship it").to_do.checked // false
::notion/to-do("Shipped", true).to_do.checked // true