{"id":13907795,"url":"https://github.com/thomashirtz/notion-utilities","last_synced_at":"2025-04-09T09:32:34.418Z","repository":{"id":41279937,"uuid":"469029665","full_name":"thomashirtz/notion-utilities","owner":"thomashirtz","description":"Tools to manipulate Notion pages and databases using Python.","archived":false,"fork":false,"pushed_at":"2022-10-17T03:46:57.000Z","size":34,"stargazers_count":14,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-24T04:08:25.941Z","etag":null,"topics":["notion","notion-api","notion-database","sdk-python","utilities"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thomashirtz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-12T08:52:19.000Z","updated_at":"2024-08-23T03:50:29.000Z","dependencies_parsed_at":"2023-01-20T00:20:10.924Z","dependency_job_id":null,"html_url":"https://github.com/thomashirtz/notion-utilities","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomashirtz%2Fnotion-utilities","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomashirtz%2Fnotion-utilities/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomashirtz%2Fnotion-utilities/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomashirtz%2Fnotion-utilities/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thomashirtz","download_url":"https://codeload.github.com/thomashirtz/notion-utilities/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248012593,"owners_count":21033226,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["notion","notion-api","notion-database","sdk-python","utilities"],"created_at":"2024-08-06T23:02:10.837Z","updated_at":"2025-04-09T09:32:34.133Z","avatar_url":"https://github.com/thomashirtz.png","language":"Python","funding_links":[],"categories":["HarmonyOS"],"sub_categories":["Windows Manager"],"readme":"# notion-utilities\n\nLibrary to perform basic transformation on notion database. It is possible to \napply function on a property or combinations of properties in order to edit properties.\n\n⚠ Use at your own risk. If you want to be safe, please apply the functions on copies of the\nproperties you want to edit (Or at least when testing the proper working of your code).\n\n## Installation\n\n```console\npip install git+https://github.com/thomashirtz/notion-utilities#egg=notion-utilities\n```\n\n## How to set up ?\n\n### 1. Creation of an integration\n\nCreate an [integration](https://www.notion.so/my-integrations) for the notion-utilities library. The integration needs to target the workplace containing the database that will be modified.\n\nOption needed:\n- [x] Read content\n- [x] Update content\n- [x] Insert content\n\nCopy the `Internal Integration Token`, it will be the `token` argument of the functions.\n\n### 2. Share the database with the Integration\n\nGo to your database in notion =\u003e Click on `Share` =\u003e `Invite` =\u003e Select the integration that you just created.\n\nCopy the link of the database (simply the URL on a browser, on the application =\u003e Click on `...` =\u003e `Copy Link`).\n\nExtract the `database_id` from the URL : `https://www.notion.so/\u003cworkspace_name\u003e/\u003cdatabase_id\u003e?v=\u003cview_id\u003e`\n\n### 3. Run your scripts\n\nCreate the script that you want to run and set the `token` and the `database_id` with the one got from the [step 1](#1-creation-of-an-integration) and the [step 2](#2-share-the-database-with-the-integration), respectively.\n\n## Examples\n\n\u003cdetails open\u003e\n\n  \u003csummary\u003e\u003cb\u003eAdd a suffix, a prefix or apply a transformation\u003c/b\u003e\u003c/summary\u003e\n\n  ```python\nfrom notion_utilities import apply_to_database\nfrom notion_utilities.properties import RichText\n\n\ndef add_suffix_and_prefix(value):\n    return 'suffix_' + value + '_prefix'\n\n\ntoken = ''\ndatabase_id = ''\n\nif __name__ == '__main__':\n    apply_to_database(\n        token=token,\n        database_id=database_id,\n        source=RichText('Input'),\n        target=RichText('Output'),\n        function=add_suffix_and_prefix,\n    )\n```\n\n\u003c/details\u003e\n\n\n\n\u003cdetails\u003e\n\n  \u003csummary\u003e\u003cb\u003ePossibility to use several properties and assign to several properties\u003c/b\u003e\u003c/summary\u003e\n\n```python\nfrom notion_utilities import apply_to_database\nfrom notion_utilities.properties import RichText\n\n\ndef transform(input_1, input_2):  \n    # some useful transformation\n    return output\n\n\ntoken = ''\ndatabase_id = ''\n\nif __name__ == '__main__':\n    apply_to_database(\n        token=token,\n        database_id=database_id,\n        source=[RichText('Input 1'), RichText('Input 2')],\n        target=RichText('Output'),\n        function=transform,\n    )\n```\n\n```python\nfrom notion_utilities import apply_to_database\nfrom notion_utilities.properties import RichText\n\n\ndef transform(input):  \n    # some useful transformation\n    return output_1, output_2\n\n\ntoken = ''\ndatabase_id = ''\n\nif __name__ == '__main__':\n    apply_to_database(\n        token=token,\n        database_id=database_id,\n        source=RichText('Input'),\n        target=[RichText('Output 1'), RichText('Output 2')],\n        function=transform,\n    )\n```\n\n\u003c/details\u003e\n\n\n\u003cdetails\u003e\n\n  \u003csummary\u003e\u003cb\u003eProperty transformation (e.g. transform chinese characters to pinyin)\u003c/b\u003e\u003c/summary\u003e\n\n```python\nimport pinyin\n\nfrom notion_utilities import apply_to_database\nfrom notion_utilities.properties import RichText\n\n\ndef get_pinyin(chinese):  \n    return pinyin.get(chinese)\n\n\ntoken = ''\ndatabase_id = ''\n\nif __name__ == '__main__':\n    apply_to_database(\n        token=token,\n        database_id=database_id,\n        source=RichText('Chinese'),\n        target=RichText('Pinyin'),\n        function=get_pinyin,\n    )\n```\n\n\u003c/details\u003e\n\n## License\n\n     Copyright 2022 Thomas Hirtz\n\n     Licensed under the Apache License, Version 2.0 (the \"License\");\n     you may not use this file except in compliance with the License.\n     You may obtain a copy of the License at\n\n         http://www.apache.org/licenses/LICENSE-2.0\n\n     Unless required by applicable law or agreed to in writing, software\n     distributed under the License is distributed on an \"AS IS\" BASIS,\n     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n     See the License for the specific language governing permissions and\n     limitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomashirtz%2Fnotion-utilities","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthomashirtz%2Fnotion-utilities","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomashirtz%2Fnotion-utilities/lists"}