Skip to main content

Unoffical Notion AI API

Project description

NotionAI

Unofficial NotionAI API

https://github.com/Vaayne/NotionAI

Feature

  • Full APIs from Notion AI
  • Support stream response

API

We support all NotionAI's functionalites. You can find all the APIs in NotionAI.py

Basic API Shortcuts

APIs like blog_post, help_me_write, help_me_edit, summarize ... are shortcuts for the basic APIs.

Advanced 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:

  1. writing_with_topic
  2. writing_with_prompt

Usage

Install

pip install --upgrade notionai-py

Get Notion Token

  1. Open Chrome / Firefix DevTools
  2. Find Cookies and copy value for token_v2

Example

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()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

notionai-py-0.0.4.tar.gz (275.0 kB view hashes)

Uploaded Source

Built Distribution

notionai_py-0.0.4-py3-none-any.whl (5.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page