Objects
objects
¶
Wrapper for various Notion API objects like parents, mentions, emojis & users.
Similar to other records, these object provide access to the primitive data structure used in the Notion API as well as higher-level methods.
For validation the Pydantic model fields specify if a field is optional or not. Some fields are always set, e.g. id
, when retrieving an object but must not be set when sending the object to the Notion API in order to create the object. To model this behavior, the default value None
is used for those objects, e.g.
class SelectOption(GenericObject)
id: str = None # type: ignore # to make sure mypy doesn't complain
Annotations
¶
Style information for RichTextObject's.
bold: bool = False
class-attribute
instance-attribute
¶
code: bool = False
class-attribute
instance-attribute
¶
color: BGColor = None
class-attribute
instance-attribute
¶
italic: bool = False
class-attribute
instance-attribute
¶
strikethrough: bool = False
class-attribute
instance-attribute
¶
underline: bool = False
class-attribute
instance-attribute
¶
BlockRef
¶
Bot
¶
Represents a Bot in Notion.
bot: _NestedData = _NestedData()
class-attribute
instance-attribute
¶
DatabaseRef
¶
DateRange
¶
EmojiObject
¶
ExternalFile
¶
FileObject
¶
A Notion file object.
Depending on the context, a FileObject may require a name (such as in the Files
property). This makes the object hierarchy difficult, so here we simply allow name
to be optional. It is the responsibility of the caller to set name
if required by the API.
LinkObject
¶
MentionData
¶
Base class for typed Mention
data objects.
MentionDatabase
¶
MentionDate
¶
MentionLinkPreview
¶
Nested url data for Mention
properties.
These objects cannot be created via the API.
link_preview: _NestedData
instance-attribute
¶
MentionPage
¶
MentionTemplate
¶
Nested template data for Mention
properties.
template_mention: MentionTemplateData
instance-attribute
¶
MentionTemplateData
¶
Nested template data for Mention
properties.
MentionTemplateDate
¶
Nested date template data for Mention
properties.
template_mention_date: str
instance-attribute
¶
MentionTemplateUser
¶
Nested user template data for Mention
properties.
template_mention_user: str
instance-attribute
¶
MentionUser
¶
Nested user data for Mention
properties.
ObjectReference
¶
PageRef
¶
ParentRef
¶
Reference another block as a parent.
Notion API: Parent Object
This class is simply a placeholder for the typed concrete *Ref classes.
Callers should always instantiate the intended concrete versions.
Person
¶
Represents a Person in Notion.
person: _NestedData = _NestedData()
class-attribute
instance-attribute
¶
RichTextObject
¶
Base class for Notion rich text elements.
annotations: Annotations | None = None
class-attribute
instance-attribute
¶
href: str | None = None
class-attribute
instance-attribute
¶
plain_text: str
instance-attribute
¶
build(text: str, href: str | None = None, style: Annotations | None = None)
classmethod
¶
Compose a TextObject from the given properties.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text | str | the plain text of this object | required |
href | str | None | an optional link for this object | None |
style | Annotations | None | an optional Annotations object for this text | None |
SelectGroup
¶
SelectOption
¶
Options for select & multi-select objects.
color: Color = Color.DEFAULT
class-attribute
instance-attribute
¶
description: str | None = None
class-attribute
instance-attribute
¶
id: str = None
class-attribute
instance-attribute
¶
name: str
instance-attribute
¶
build(name, color=Color.DEFAULT)
classmethod
¶
Create a SelectOption
object from the given name and color.
TextObject
¶
Notion text element.
text: _NestedData = _NestedData()
class-attribute
instance-attribute
¶
build(text: str, href: str | None = None, style: Annotations | None = None)
classmethod
¶
Compose a TextObject from the given properties.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
text | str | the plain text of this object | required |
href | str | None | optional link for this object | None |
style | Annotations | None | optional annotations for styling this text | None |
User
¶
UserRef
¶
Reference to a user, e.g. in created_by
, last_edited_by
, mentioning, etc.