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: Color | BGColor = Color.DEFAULT
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
¶
Comment
¶
CommentRef
¶
DatabaseRef
¶
DateRange
¶
A Notion date range, with an optional end date.
end: dt.date | dt.datetime | None = None
class-attribute
instance-attribute
¶
start: dt.date | dt.datetime
instance-attribute
¶
time_zone: str | None = None
class-attribute
instance-attribute
¶
__str__() -> str
¶
build(dt_spec: str | dt.datetime | dt.date | pnd.Interval) -> DateRange
classmethod
¶
Compose a DateRange object from the given properties.
build_mention(style: Annotations | None = None) -> MentionObject
¶
to_pendulum() -> pnd.DateTime | pnd.Date | pnd.Interval
¶
Convert the DateRange to a pendulum object.
EmojiObject
¶
EquationObject
¶
Notion equation element.
equation: TypeData
instance-attribute
¶
build(expression: str, *, href: str | None = None, style: Annotations | None = None) -> EquationObject
classmethod
¶
Compose a TextObject from the given properties.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
expression | str | expression | required |
href | str | None | optional link for this object | None |
style | Annotations | None | optional annotations for styling this text | None |
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.
HostedFile
¶
LinkObject
¶
MentionBase
¶
Base class for typed Mention
objects.
MentionDatabase
¶
MentionDate
¶
MentionLinkPreview
¶
MentionMixin
¶
Mixin for objects that can be mentioned in Notion.
This mixin adds a mention
property to the object, which can be used to reference the object in a mention.
build_mention(style: Annotations | None = None) -> MentionObject
abstractmethod
¶
Return a mention object for this object.
MentionPage
¶
MentionTemplate
¶
Nested template data for Mention
properties.
template_mention: SerializeAsAny[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
¶
ObjectRef
¶
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
¶
RichTextBaseObject
¶
SelectGroup
¶
SelectOption
¶
Options for select & multi-select objects.
color: Color = Color.DEFAULT
class-attribute
instance-attribute
¶
description: list[RichTextBaseObject] | None = None
class-attribute
instance-attribute
¶
id: str = None
class-attribute
instance-attribute
¶
name: str
instance-attribute
¶
build(name, color=Color.DEFAULT) -> SelectOption
classmethod
¶
Create a SelectOption
object from the given name and color.
TextObject
¶
Notion text element.
text: TypeData = TypeData()
class-attribute
instance-attribute
¶
TypeData
¶
build(text: str, *, href: str | None = None, style: Annotations | None = None) -> TextObject
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 |
UnknownUser
¶
User
¶
UserRef
¶
Reference to a user, e.g. in created_by
, last_edited_by
, mentioning, etc.
build(user_ref: User | str | UUID) -> UserRef
classmethod
¶
Compose a PageRef from the given reference object.
get_uuid(obj: str | UUID | ParentRef | NotionObject | BlockRef) -> UUID
¶
Retrieves a UUID from an object reference.
Only meant for internal use.
rich_text_to_str(rich_texts: list[RichTextBaseObject]) -> str
¶
Convert a list of rich texts to plain text.