Unofficial NotionAI API
https://github.com/Vaayne/NotionAI
The NotionAI Chrome Extension is an open-source tool that provides a simple way to access the NotionAI API. It allows you to use NotionAI in any input field in Chrome with ease.
NotionAI Python SDK, a wrapper for the NotionAI APIs with Python bindings. It simplifies integrating NotionAI solutions into your projects.
- Full APIs from Notion AI
- Support stream response
We support all NotionAI's functionalites. You can find all the APIs in NotionAI.py
APIs like blog_post, help_me_write, help_me_edit, summarize ... are shortcuts for the basic APIs.
Some times we don't want to call apis one by one, we want to dispatch by parameters, these are advanced APIs.
We support these advanced APIs:
writing_with_topic
Writing for special topic Args: topic (TopicEnum): the special topic prompt (str): prompt for writing Example: ao = NotionAI(token) ai.writing_with_topic(TopicEnum.blog_post, "Please help to introduce Notion")
writing_with_prompt
Writing with special prompt, like summarize, explain_this, improve_writing Args: prompt_type (PromptTypeEnum): special prompt context (str): the context for your writing Example: ai = NotionAI(token) ai.writing_with_prompt(PromptTypeEnum.summarize, "I am a student")
translate
Translate the text Args: language (TranslateLanguageEnum): target language context (str): context to translate Example: ai = NotionAI(token) ai.translate(TranslateLanguageEnum.Chinese, "I am a student")
pip install --upgrade notionai-py
- Open Chrome / Firefix DevTools
- Find Cookies and copy value for
token_v2
Please checkout examples
- Basic
import os
from notionai import NotionAI
TOKEN = os.getenv("NOTION_TOKEN")
def main():
ai = NotionAI(TOKEN)
res = ai.blog_post("write a blog about the meaning of life")
print(res)
if __name__ == "__main__":
main()
- Stream API
import os
import sys
from notionai import NotionAI
TOKEN = os.getenv("NOTION_TOKEN")
def main():
ai = NotionAIStream(TOKEN)
res = ai.blog_post("write a blog about the meaning of life")
for item in res:
sys.stdout.write(item)
if __name__ == "__main__":
main()
- WebUI