Package: easyNotion
easyNotion APIEnglish|简体中文:muscle: Function IntroductionA simpler and faster Notion API wrapper compared to other existing ones.Closes proxies when sending requests.Provides basic CRUD (Create, Read, Update, Delete) operations.:bangbang: Usage LimitationsOnly applicable to Notion pages of type "Database - Full page".All column properties in the database, except the title column, must be of type "text".There is no asynchronous version available.:wrench: Quick StartFirst, you need to obtain the Token and database_id for integrating with Notion. To learn how to obtain the Token, please refer tothis link. To get the database_id, check the URL of the database page in the Notion documentation.fromeasyNotionimporteasyNotiondb=easyNotion(database_id='database_id',token='token')# Get the entire table (unprocessed)table_all=db.getTableAll()# Get the processed tabletable=db.getTable()# Query a specific column based on the column nameret=db.queryCol(col="column_name")# Query rows based on a specific columnrow=db.queryRow(col="column_name",content="column_content")# Get the total number of rowsrow_count=db.getRowCnt()# Insert datadata={"title":"test_title","column_name1":"value1","column_name2":"value2"}res=db.insert(data=data)# Update datares=db.update(col="column_name",content="column_content",update_col="update_column_name",update_content="new_value",isTitle=False)# Delete datares=db.delete(col="column_name",content="column_content")# Close the sessiondb.closeSession()Class: easyNotionConstructordef__init__(self,database_id,token)Initializes a new instance of theeasyNotionclass.Parameters:database_id(str): The ID of the Notion database.token(str): The API token used to access the Notion API.Class AttributesbaseUrlType: StringDescription: The base URL of the API.database_idType: StringDescription: The ID of the database.headersType: DictionaryDescription: Request headers, including Accept, Notion-Version, Content-Type, Authorization, etc.sessionType:requests.SessionobjectDescription: Session object used to send HTTP requests.tableType: ListDescription: Processed data table containing all rows from the database.MethodsgetTableAll()defgetTableAll(self)->dictRetrieves the raw data table from the Notion database.Returns:JSON object containing all raw data from the database.getTable()defgetTable(self)->listRetrieves the processed data table from the Notion database.Returns:List of dictionaries representing the processed data table.Note:This method internally callsgetTableAll()to retrieve the raw data and process it to obtain the final data table.queryCol(col: str) -> listdefqueryCol(self,col:str)->listQueries a specific column in the data table and returns its values.Parameters:col(str): Name of the column to query.Returns:List of strings containing the values in the specified column.queryRow(col: str, content: str) -> dictdefqueryRow(self,col:str,content:str)->dictQueries a row in the data table based on a specific column and its content.Parameters:col(str): Name of the column to search.content(str): Value to search in the specified column.Returns:Dictionary representing the raw data of the matching row.Note:If no matching row is found, an empty dictionary{}is returned.getRowCnt() -> intdefgetRowCnt(self)->intRetrieves the total number of rows in the data table.Returns:Integer representing the total number of rows in the table.insert(data: dict)definsert(self,data:dict)Inserts data into the Notion database.Parameters:data(dict): Data to insert. The first value in the dictionary must correspond to the value of the "title" column.Returns:Response object of the API request.update(col: str, content: str, update_col: str, update_content: str, isTitle=False)defupdate(self,col:str,content:str,update_col:str,update_content:str,isTitle=False)Updates a specific column of a row in the data table.Parameters:col(str): Column used to identify the row.content(str): Content of the specified column used to identify the row.update_col(str): Name of the column to update.update_content(str): New content to update in the specified column.isTitle(bool): Indicates whether the specified column is the title column. Default isFalse. Set toTrueif the column being updated is the title column.Returns:Response object of the API request.delete(col: str, content: str)defdelete(self,col:str,content:str)Deletes a row from the data table based on a specific column and its content.Parameters:col(str): Name of the column to delete.content(str): Value that identifies the row to delete in the specified column.Returns:Response object of the API request.closeSession()defcloseSession(self)Closes the session used for API requests.