Skip to content

Core

core

Core classes and functions for the Ultimate Notion API.

GT_co = TypeVar('GT_co', bound=(obj_core.GenericObject), default=(obj_core.GenericObject), covariant=True) module-attribute

NE_co = TypeVar('NE_co', bound=(obj_core.NotionEntity), default=(obj_core.NotionEntity), covariant=True) module-attribute

NO_co = TypeVar('NO_co', bound=(obj_core.NotionObject), default=(obj_core.NotionObject), covariant=True) module-attribute

Workspace: Final = _Workspace.ROOT module-attribute

This represents the actual root workspace in Notion.

WorkspaceType: TypeAlias = Literal[_Workspace.ROOT] module-attribute

This represents the type of the root workspace in Notion for type hinting.

NotionEntity(*args: Any, **kwargs: Any)

ancestors: tuple[NotionEntity, ...] property

Return all ancestors from the workspace to the actual record (excluding).

created_by: User property

Return the user who created the block.

created_time: dt.datetime property

Return the time when the block was created.

id: UUID property

Return the ID of the entity.

is_db: bool property

Return whether the object is a database.

is_page: bool property

Return whether the object is a page.

last_edited_time: dt.datetime property

Return the time when the block was last edited.

parent: NotionEntity | WorkspaceType | None property

Return the parent Notion entity, Workspace if the workspace is the parent, or None if not accessible.

__eq__(other: object) -> bool

__hash__() -> int

NotionObject(*args: Any, **kwargs: Any)

A top-level Notion API resource.

id: UUID | str property

Return the ID of the block.

in_notion: bool property

Return whether the block was created in Notion.

Wrapper(*args: Any, **kwargs: Any)

Convert objects from the obj-based API to the high-level API and vice versa.

obj_ref: GT_co property writable

Return the low-level Notion-API object reference.

This is just the answer of the Notion API as a Pydantic model.

__init_subclass__(wraps: type[GT_co], **kwargs: Any)

__new__(*args: Any, **kwargs: Any) -> Self

__pydantic_serializer__() -> SchemaSerializer

Return the Pydantic serializers for this object.

wrap_obj_ref(obj_ref: GT_co) -> Self classmethod

Wraps low-level obj_ref from Notion API into a high-level (hl) object of Ultimate Notion.

get_active_session() -> Session

Return the current active session or raise an exception.

Avoids cyclic imports when used within the package itself. For internal use mostly.

get_repr(obj: Any, /, *, name: Any = None, desc: Any = None) -> str

Default representation, i.e. repr(...), used by us for consistency.

get_url(object_id: UUID | str) -> str

Return the URL for the object with the given id.