KNotionDatabases

Interface for managing Notion databases through the Notion API. This interface provides methods to create, retrieve, update, and query databases in your Notion workspace. Databases can be created as children of pages and can contain various property types and content.

Example usage:

// Retrieve a database
val database = client.databases.getDatabase("database-id")

// Query a database
val results = client.databases.queryDatabase(
id = "database-id",
query = DatabaseQuery().apply {
filter("Status", "equals", "Done")
}
)

Functions

Link copied to clipboard
abstract suspend fun createDatabase(parentPageId: UuidString, title: RichTextList = RichTextList(), icon: EmojiOrFile? = null, cover: File? = null, properties: PropertySpecList = PropertySpecList()): Database

Creates a new database as a child of a page. The database must have at least one title property defined in the properties list.

Link copied to clipboard
abstract suspend fun getDatabase(id: UuidString): Database

Retrieves a database by its ID. This method fetches all database properties, schema, and metadata.

Link copied to clipboard
abstract suspend fun getDatabaseList(pagination: Pagination = Pagination()): ResultPage<Database>

Lists all databases that have been shared with your integration. This method returns a paginated list of databases that your integration has access to.

Link copied to clipboard
abstract suspend fun queryDatabase(id: UuidString, query: DatabaseQuery? = null, sort: PropertySort? = null, pagination: Pagination = Pagination()): ResultPage<Page>

Queries a database for pages that match specific criteria. This method allows you to filter, sort, and paginate through database contents.

Link copied to clipboard
abstract suspend fun updateDatabase(id: UuidString, title: RichTextList? = null, icon: EmojiOrFile? = null, cover: File? = null, properties: PropertySpecList? = null): Database

Updates an existing database's properties. This method allows you to modify the database's title, icon, cover, and property schema.