NotionAI Go Save

Unofficial NotionAI Go SDK

Project README

NotionAI-go

NotionAI-go is an unofficial NotionAI API that provides a Go SDK, inspired by https://github.com/Vaayne/NotionAI.

NotionAI Go SDK

The NotionAI Go SDK is a wrapper for the All NotionAI APIs, you can use it to simplify integration of NotionAI solutions into your projects.

Usage

Installing

Use go get to retrieve the SDK to add it to your GOPATH workspace, or project's Go module dependencies.

go get github.com/jyz0309/notionAI-go

Get Notion Token and Workspace ID

To use the NotionAI Go SDK, you need to obtain a Notion token. You can do this by following these steps:

  1. Open your browser DevTools
  2. Find the spaceId of your Notion workspace in the request body.
  3. Find the request cookies and copy the value for token_v2

Get Notion Token

Get Notion Workspace ID

Init the client

First, you need to use the token and spaceID to init notion AI client, just like this:

import "github.com/jyz0309/notionAI-go/client"

func main(){
	cli := client.NewClient("Your notion token", "Your notion space ID")
    //...
}

After init the client, you can use client to call notion AI API in pkg.

API Introduction

All NotionAI APIs are supported. You can check the client package to see all APIs.

  1. WriteWithTopic
/*
Usage: WriteWithTopic writes for special topic, like Blog, Essay, Todo list
Args:
    topic(TopicType): the special topic
    prompt(string): prompt for writing
*/
// Example:
func main(){
	cli := client.NewClient("Your notion token", "Your notion space ID")
    cli.WriteWithTopic(common.BlogPost, "Golang")
}
  1. WriteWithPrompt
/*
Usage: WriteWithPrompt writes with special prompt, like summarize, explain_this, improve_writing
Args:
    promptType(PromptType): the special prompt
    content(string): the content for your writing
*/
// Example:
func main() {
	cli := client.NewClient("Your notion token", "Your notion space ID")
	cli.WriteWithPrompt(common.MakeLonger, "Today is friday!")
}
  1. Translate
/*
Usage: Translate will translate the content to given language
Args:
    lang(SupportedLanguage): the target language
    prompt(string): content to translate
*/
// Example:
func main() {
	cli := client.NewClient("Your notion token", "Your notion space ID")
	cli.Translate(common.Chinese, "Today is friday!")
}
  1. ChangeTone
/*
Usage: ChangeTone uses specific tones to optimize content.
Args:
    tone(SupportedTone): the target tone
    prompt(string): content to change
*/
// Example:
func main() {
	cli := client.NewClient("Your notion token", "Your notion space ID")
	cli.ChangeTone(common.Professional, "Today is friday!")
}
  1. ContinueWriting
/*
Usage: ContinueWriting can generate the following content based on the given input content.
Args:
    content(string): content to continue writing
*/
// Example:
func main() {
	cli := client.NewClient("Your notion token", "Your notion space ID")
	cli.ContinueWriting("Today is friday!")
}
  1. HelpMeDraft
/*
Usage: HelpMeDraft can generate a draft based on the given prompt.
Args:
    prompt(string): prompt used to generate a draft
*/
// Example:
func main() {
	cli := client.NewClient("Your notion token", "Your notion space ID")
	cli.HelpMeDraft("How the nation AI work?")
}
  1. HelpMeEdit
/*
Usage: HelpMeEdit can optimize content based on the given prompt.
Args:
    content(string): content you need to optimize
    prompt(string): prompt used to generate a draft
*/
// Example:
func main() {
	cli := client.NewClient("Your notion token", "Your notion space ID")
	cli.HelpMeEdit("The content is about how the nation AI work", "please help me make it longer.")
}

Example


func main() {
	cli := client.NewClient("Your notion token", "Your notion space ID")
	resp, err := cli.ContinueWriting("Deploy a mysql service")
	if err != nil {
		log.Default().Panic(err)
		return
	}
	/* resp:
    To deploy a mysql service, you can use a containerization tool such as Docker or Kubernetes. 
    First, you'll need to create a Dockerfile or Kubernetes deployment file that includes the mysql image and any necessary environment variables or configuration options. 
    You can then use the appropriate tool to build and deploy the container, making sure to expose the necessary ports and configure any required network settings.
    */
}

Open Source Agenda is not affiliated with "NotionAI Go" Project. README Source: jyz0309/NotionAI-go
Stars
57
Open Issues
2
Last Commit
7 months ago
Repository
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating