iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🤖

Created a Google Apps Script Library for Interacting with Notion

に公開
2024/04/08
2件

Introduction

I created a library to make the Notion API easier to use.

Library Installation

Here is the Script ID.

1P5ARr7gp69EnBgiNMVEVboO-M-XESgTSycWU2WWBuIvdxtFsYk4MlyG0

The current latest version is version 3 (December 19, 22:27).

Reference
https://gadgelaun.com/?p=27642#:~:text=まとめ-,GASのライブラリ追加方法,追加することができる。

Usage

Example

const NOTION_CONFIG = {
  token: '', // token
  db_id: {
    test: '', // Database ID
  },
};

// Instantiating the manager class
const notionManager = Notion.initManager(NOTION_CONFIG.token);

// Instantiating the record class
const record = Notion.initRecord();

// Setting the title
notionRecord.setTitle('name', '新版 市場を創る:バザールからネット取引まで');
// Setting the icon
notionRecord.setIcon('📗');
// Setting the URL property. The first argument is the property name.
notionRecord.setPropertiesUrl('url', 'https://www.amazon.co.jp/dp/4766427831');

// Creating a record with the configured content in Notion.
notionManager.createRecord(NOTION_CONFIG.db_id.test, record);

List of Methods

Source

https://github.com/nag8/NotionManagerGAS

Inserting the Body Text

notionRecord.pushChildrenText('This is the body text');

Setting Properties

Date

const date = dayjs.dayjs();
notionRecord.setPropertiesDate('日付', date);


// If there is an end date/time
const startDate = dayjs.dayjs();
const endDate = dayjs.dayjs();
notionRecord.setPropertiesDate('日付', startDate, endDate);

// If including time
notionRecord.setPropertiesDatetime('日付', startDate, endDate);

Select

notionRecord.setPropertiesSelect('タグ', '本');

Number

notionRecord.setPropertiesNumber('ポイント', 500);

You can find implemented and pending features here. If you have any feature requests, please post them in this project and I might take a look.
https://github.com/users/nag8/projects/1

Discussion

TAKAHIROTAKAHIRO

このライブラリを使ってみたいのですが、イマイチ使い方がわからなくてコメントさせていただきました。
このライブラリを使ったら、Notionにつかったデータベースの内容をスプレッドシートに転記することは可能でしょうか?