Giter Site home page Giter Site logo

notionai-go's Introduction

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.
    */
}

notionai-go's People

Contributors

jyz0309 avatar licells avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.