{"id":13737446,"url":"https://github.com/vaayne/notionai-py","last_synced_at":"2025-05-08T13:34:05.282Z","repository":{"id":152233515,"uuid":"613379180","full_name":"vaayne/notionai-py","owner":"vaayne","description":"Unofficial Python SDK for NotionAI ","archived":false,"fork":false,"pushed_at":"2024-01-24T02:12:13.000Z","size":721,"stargazers_count":62,"open_issues_count":1,"forks_count":12,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-04-04T09:36:40.655Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vaayne.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-13T13:10:11.000Z","updated_at":"2025-03-26T11:04:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"e0ecc35c-8e8e-4a22-8cd9-72f9843ece2f","html_url":"https://github.com/vaayne/notionai-py","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vaayne%2Fnotionai-py","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vaayne%2Fnotionai-py/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vaayne%2Fnotionai-py/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vaayne%2Fnotionai-py/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vaayne","download_url":"https://codeload.github.com/vaayne/notionai-py/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253077685,"owners_count":21850368,"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":[],"created_at":"2024-08-03T03:01:48.136Z","updated_at":"2025-05-08T13:34:00.254Z","avatar_url":"https://github.com/vaayne.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# NotionAI Python SDK\n\nThe NotionAI Python SDK is a wrapper for the NotionAI APIs with Python bindings, simplifying integration of NotionAI solutions into your projects.\n\n### Features\n\n- Full APIs from Notion AI\n- Support stream response\n\n### API\n\nAll NotionAI functionalities are supported. Check out the [notionai.py](./notionai/notionai.py) file to see all the available APIs.\n\n#### Basic API Shortcuts\n\nAPIs like `blog_post`, `help_me_write`, `help_me_edit`, and `summarize` are shortcuts for the basic APIs.\n\n#### Advanced APIs\n\nWe also support advanced APIs that allow you to dispatch by parameters:\n\n1. `writing_with_topic`\n    ```\n    Writing for special topic\n    Args:\n        topic (TopicEnum): the special topic\n        prompt (str): prompt for writing\n    Example:\n        ao = NotionAI(token)\n        ai.writing_with_topic(TopicEnum.blog_post, \"Please help to introduce Notion\")\n    ```\n2. `writing_with_prompt`\n    ```\n    Writing with special prompt, like summarize, explain_this, improve_writing\n\n    Args:\n        prompt_type (PromptTypeEnum): special prompt\n        context (str): the context for your writing\n\n    Example:\n        ai = NotionAI(token)\n        ai.writing_with_prompt(PromptTypeEnum.summarize, \"I am a student\")\n    ```\n3. `translate`\n    ```\n    Translate the text\n    Args:\n        language (TranslateLanguageEnum): target language\n        context (str): context to translate\n\n    Example:\n        ai = NotionAI(token)\n        ai.translate(TranslateLanguageEnum.Chinese, \"I am a student\")\n    ```\n4. `change_tone`\n   ```\n    Change the tone of your context\n    Args:\n        context (str): context to change\n        tone (ToneEnum): target tone\n\n    Returns:\n        str: Response from NotionAI\n    Example:\n        ai = NotionAI(token)\n        ai.change_tone(\"I am a student\", ToneEnum.professional)\n   ```\n\n### Usage\n\n#### Install\n\n`pip install --upgrade notionai-py`\n\n#### Get Notion Token and Workspace ID\n\nTo use the NotionAI Python SDK, you need to obtain a Notion token. You can do this by following these steps:\n\n1. Open Chrome or Firefox DevTools\n2. Find Cookies and copy the value for `token_v2`\n3. Find the `spaceId` of your Notion workspace\n\n- get notion token\n![Get Notion Token](./docs/images/get_notion_token.png)\n- get notion workspace id\n![Get Notion Workspace ID](./docs/images/notion-space-id.png)\n\n**Note: Now can get Notion space id using api**\n\n```python\nimport os\nfrom notionai import NotionAI\nTOKEN = os.getenv(\"NOTION_TOKEN\")\n\nspaces = NotionAI.get_spaces(TOKEN)\nprint(spaces)\n# the result will looks like\n# [{'id': 'xxxxx', 'name': 'xxxxx'}]\n\n```\n\n**Note2: Now supports custom api proxy links**\n\n```python\nimport os\nfrom notionai import NotionAI\nTOKEN = os.getenv(\"NOTION_TOKEN\")\nSPACE_ID = os.getenv(\"NOTION_SPACE_ID\")\nAPI_URL = \"https://xxx.xxx.xxx\"  # this is your custom proxy links\n\nai = NotionAI(TOKEN, SPACE_ID, api_url=API_URL)\nres = ai.blog_post(\"write a blog about the meaning of life\")\nprint(res)\n```\n\n#### Examples\n\nCheck out the [examples](./examples/) directory for usage examples.\n\n1. Basic\n\n```python\nimport os\nfrom notionai import NotionAI\n\nTOKEN = os.getenv(\"NOTION_TOKEN\")\nSPACE_ID = os.getenv(\"NOTION_SPACE_ID\")\n\ndef main():\n    ai = NotionAI(TOKEN, SPACE_ID)\n    res = ai.blog_post(\"write a blog about the meaning of life\")\n    print(res)\n\nif __name__ == \"__main__\":\n    main()\n\n```\n\n2. Stream API\n\n```python\nimport os\nimport sys\nfrom notionai import NotionAI\n\nTOKEN = os.getenv(\"NOTION_TOKEN\")\nSPACE_ID = os.getenv(\"NOTION_SPACE_ID\")\n\ndef main():\n    ai = NotionAIStream(TOKEN, SPACE_ID)\n    res = ai.blog_post(\"write a blog about the meaning of life\")\n    for item in res:\n        sys.stdout.write(item)\n\nif __name__ == \"__main__\":\n    main()\n```\n\n3. WebUI\n\nCheck out the [webui](./examples/webui/README.md) directory for instructions on how to use the NotionAI Python SDK with a web user interface.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaayne%2Fnotionai-py","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvaayne%2Fnotionai-py","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaayne%2Fnotionai-py/lists"}