Iterator
iterator
¶
Iterator classes for working with paginated API responses.
MAX_PAGE_SIZE = 100
module-attribute
¶
T = TypeVar('T', bound=NotionObject)
module-attribute
¶
BlockList
¶
CommentList
¶
EndpointIterator(endpoint: Callable[..., Any | Awaitable[Any]], model_validate: Callable[[Any], NotionObject] = ObjectList.model_validate)
¶
Functor to iterate over results from a potentially paginated API response.
In most cases notion_obj
should be ObjectList
. For some endpoints, like PropertiesEndpoint
, and endpoint returns a list of property items or s single property item. In this case, model_validate
should be TypeAdapter(PropertyItemList | PropertyItem).validate_python
or whatever you expect to be returned.
has_more: bool | None = None
class-attribute
instance-attribute
¶
next_cursor: str | None = None
class-attribute
instance-attribute
¶
page_num: int = -1
class-attribute
instance-attribute
¶
total_items: int = -1
class-attribute
instance-attribute
¶
__call__(**kwargs: Any) -> Iterator[T]
¶
Return a generator for this endpoint using the given parameters.
ObjectList
¶
A paginated list of objects returned by the Notion API.
More details in the Notion API.
PageOrDatabaseList
¶
PropertyItemList
¶
A paginated list of property items returned by the Notion API.
Property item lists contain one or more pages of basic property items. These types do not typically match the schema for corresponding property values.
UserList
¶
convert_to_notion_obj(data: dict[str, Any]) -> Block | Page | Database | PropertyItem | User | GenericObject
¶
Convert a dictionary to the corresponding subtype of Notion Object.
Used in the ObjectList below the convert the results from the Notion API.