Skip to content

Core

core

Core classes and functions for the Ultimate Notion API.

GT = TypeVar('GT', bound=obj_core.GenericObject) module-attribute

NE = TypeVar('NE', bound=obj_core.NotionEntity) module-attribute

NO = TypeVar('NO', bound=obj_core.NotionObject) module-attribute

InvalidAPIUsageError(message='This part of the API is not intended to be used in this manner')

Raised when the API is used in an invalid way.

message = message instance-attribute

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 | None property

Return the parent Notion entity or None if the workspace is the parent.

__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.

ObjRefWrapper

Wrapper for objects that have an obj_ref attribute.

Note: This allows us to define Mixin classes that require the obj_ref attribute.

obj_ref: GT instance-attribute

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

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

obj_ref: GT = obj_api_type.build(*args, **kwargs) instance-attribute

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

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

wrap_obj_ref(obj_ref: GT) -> 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.