KNotionPages

interface KNotionPages

Interface for managing Notion pages through the Notion API. This interface provides methods to create, retrieve, update, and archive pages in your Notion workspace. Pages can be created either as children of databases or other pages, with support for various content types and properties.

Example usage:

// Retrieve a page
val page = client.pages.getPage("page-id")

// Create a page in a database
val newPage = client.pages.createPage(
parentDatabase = DatabaseReference("database-id"),
properties = PropertyValueList().apply {
title("Name", "My New Page")
}
)

Functions

Link copied to clipboard
abstract suspend fun createPage(parentDatabase: DatabaseReference, icon: EmojiOrFile? = null, cover: File? = null, properties: PropertyValueList = PropertyValueList(), content: MutableBlockList? = null): Page

Creates a new page as a child of a database. This method allows you to create a page with custom properties and optional content blocks.

abstract suspend fun createPage(parentDatabase: DatabaseReference, icon: EmojiOrFile? = null, cover: File? = null, properties: PropertyValueList = PropertyValueList(), content: BlockListProducer): Page

Creates a new page as a child of a database using a block producer. This overload allows for more dynamic block creation using a BlockListProducer.

abstract suspend fun createPage(parentPage: PageReference, title: RichTextList = RichTextList(), icon: EmojiOrFile? = null, cover: File? = null, content: MutableBlockList? = null): Page

Creates a new page as a child of another page. This method creates a subpage with a title and optional content blocks.

abstract suspend fun createPage(parentPage: PageReference, title: RichTextList = RichTextList(), icon: EmojiOrFile? = null, cover: File? = null, content: BlockListProducer): Page

Creates a new page as a child of another page using a block producer. This overload allows for more dynamic block creation using a BlockListProducer.

Link copied to clipboard
abstract suspend fun getPage(id: UuidString): Page

Retrieves a page by its ID. This method fetches all page properties, content, and metadata.

Link copied to clipboard
abstract suspend fun setPageArchived(id: UuidString, archived: Boolean): Page

Archives or unarchives a page. Archived pages are not deleted but are hidden from the Notion UI. They can be unarchived later using this method with archived = false.

Link copied to clipboard
abstract suspend fun updatePage(id: UuidString, icon: EmojiOrFile? = null, cover: File? = null, properties: PropertyValueList): Page

Updates the properties of an existing page. This method allows you to modify the page's icon, cover, and properties. Note that page content cannot be updated using this method - use KNotionBlocks instead.