notion_python_client.handlers package#
Submodules#
notion_python_client.handlers.database_handler module#
- class notion_python_client.handlers.database_handler.DatabaseHandler(client: Client, path)#
Bases:
Handler- get_pages(database_id: str, filter: Dict | None = None) List[Page]#
Get all pages from a database that match the filter
- Parameters:
database_id (str) – The id of the database where the pages should be retrieved from
filter (dict, optional) – The filter that should be applied. Defaults to None.
- Returns:
The pages that match the filter
- Return type:
List[Page]
notion_python_client.handlers.handler module#
notion_python_client.handlers.page_handler module#
- class notion_python_client.handlers.page_handler.PageHandler(client: Client, path)#
Bases:
Handler- create_page(parent_id: str, properties: Dict, children: Dict | None = None, cover: File | Dict | str | None = None, icon: Dict | None = None) Page#
Create a new page with the given properties
- Parameters:
parent_id (str) – The id of the parent page
properties (Dict) – The properties of the new page
children (Dict) – The children of the new page
cover (Optional[Union[File, Dict, str]]) – The cover of the page. Can be a File object, a dict or a string. If a string is provided, it will be interpreted as a url. If a dict is provided, it will be interpreted as a File object. Defaults to None.
icon (Optional[Dict]) – The icon of the page. Defaults to None.
- Returns:
The created page
- Return type:
- delete_page(page_id: str) Page#
The deletion of a page is the equivalent of archiving it. Therefore, this method will just archive the page.
- Parameters:
page_id (str) – Page id of the page that should be deleted
- Returns:
Deleted page
- Return type:
Dict
- get_page(page_id: str) Page#
Get a page with the given id
- Parameters:
page_id (str) – Page id of the page that should be retrieved
- Returns:
Retrieved page
- Return type:
- set_title_to_relation(page: Page, relation_property_name: str, title_property_name: str, relation_idx: int = 0) Page#
Sets the title of a page to the title of the relation
- Parameters:
page (Page) – The page that should be updated
relation_property_name (str) – The name of the relation property
title_property_name (str) – The name of the title property. This property will be updated with the title of the relation
relation_idx (int, optional) – The index of the relation that should be used. Can be used when multiple relations are available. Defaults to 0.
- Returns:
The updated page
- Return type:
Dict
- update_page(page_id: str | None = None, updates: Dict | None = None, page: Page | None = None) Page#
Update a specifc page with the content in the updates dict
- Parameters:
page_id (str, optional) – The id of the page that should be updated. Defaults to None.
updates (Dict, optional) – The updates that should be applied. Defaults to None.
page (Page, optional) – The page that should be updated. If a page is provided, the page_id and updates arguments will be ignored. Defaults to None.
- Returns:
Updated page
- Return type:
- update_status(page_id: str, property_name: str, status: str) Page#
Updates the status property of a page
- Parameters:
page_id (str) – Page id of the page that should be updated
property_name (str) – The name of the status property
status (str) – The status that should be set
- Returns:
The updated page
- Return type:
Dict
- update_title(page_id: str, property_name: str, title: str) Page#
Updates the title property of a page
- Parameters:
page_id (str) – Page id of the page that should be updated
property_name (str) – The name of the title property
title (str) – The title that should be set
- Returns:
The updated page
- Return type:
Dict
Module contents#
- class notion_python_client.handlers.DatabaseHandler(client: Client, path)#
Bases:
Handler- get_pages(database_id: str, filter: Dict | None = None) List[Page]#
Get all pages from a database that match the filter
- Parameters:
database_id (str) – The id of the database where the pages should be retrieved from
filter (dict, optional) – The filter that should be applied. Defaults to None.
- Returns:
The pages that match the filter
- Return type:
List[Page]
- class notion_python_client.handlers.PageHandler(client: Client, path)#
Bases:
Handler- create_page(parent_id: str, properties: Dict, children: Dict | None = None, cover: File | Dict | str | None = None, icon: Dict | None = None) Page#
Create a new page with the given properties
- Parameters:
parent_id (str) – The id of the parent page
properties (Dict) – The properties of the new page
children (Dict) – The children of the new page
cover (Optional[Union[File, Dict, str]]) – The cover of the page. Can be a File object, a dict or a string. If a string is provided, it will be interpreted as a url. If a dict is provided, it will be interpreted as a File object. Defaults to None.
icon (Optional[Dict]) – The icon of the page. Defaults to None.
- Returns:
The created page
- Return type:
- delete_page(page_id: str) Page#
The deletion of a page is the equivalent of archiving it. Therefore, this method will just archive the page.
- Parameters:
page_id (str) – Page id of the page that should be deleted
- Returns:
Deleted page
- Return type:
Dict
- get_page(page_id: str) Page#
Get a page with the given id
- Parameters:
page_id (str) – Page id of the page that should be retrieved
- Returns:
Retrieved page
- Return type:
- set_title_to_relation(page: Page, relation_property_name: str, title_property_name: str, relation_idx: int = 0) Page#
Sets the title of a page to the title of the relation
- Parameters:
page (Page) – The page that should be updated
relation_property_name (str) – The name of the relation property
title_property_name (str) – The name of the title property. This property will be updated with the title of the relation
relation_idx (int, optional) – The index of the relation that should be used. Can be used when multiple relations are available. Defaults to 0.
- Returns:
The updated page
- Return type:
Dict
- update_page(page_id: str | None = None, updates: Dict | None = None, page: Page | None = None) Page#
Update a specifc page with the content in the updates dict
- Parameters:
page_id (str, optional) – The id of the page that should be updated. Defaults to None.
updates (Dict, optional) – The updates that should be applied. Defaults to None.
page (Page, optional) – The page that should be updated. If a page is provided, the page_id and updates arguments will be ignored. Defaults to None.
- Returns:
Updated page
- Return type:
- update_status(page_id: str, property_name: str, status: str) Page#
Updates the status property of a page
- Parameters:
page_id (str) – Page id of the page that should be updated
property_name (str) – The name of the status property
status (str) – The status that should be set
- Returns:
The updated page
- Return type:
Dict
- update_title(page_id: str, property_name: str, title: str) Page#
Updates the title property of a page
- Parameters:
page_id (str) – Page id of the page that should be updated
property_name (str) – The name of the title property
title (str) – The title that should be set
- Returns:
The updated page
- Return type:
Dict