Skip to content
API wrapper for Notion's database [WIP]
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows add test Oct 3, 2019
.vscode beta version Aug 17, 2019
src fix client type-transform bug & add utils to nb instance Oct 23, 2019
test add test Oct 3, 2019
.gitignore init Aug 10, 2019 fix typo Oct 11, 2019
package-lock.json 0.8.1 Oct 23, 2019
package.json 0.8.1 Oct 23, 2019
yarn.lock add test Oct 3, 2019

Notabase (WIP)

API Wrapper For Notion's Database

Getting Started


yarn add notabase


You can use notabse in browser, browser extension, and node. But there is a difference when initializing the notabase instance.


Env Token Read Write Note
node public data you can only read public data without token
node private data you can read and modify private data with token
import Notabase from 'notabase'

// node env
// just Read public data
let nb = new Notabase()
// CRUD support
let nb = new Notabase({
  token: "token_v2 from cookies"


If you want to use Notabase in your web pages, you need to handle CORS. You can solve this problem with a cloudflare worker.Generate a cloudflare-worker using the code from src/cf-worker.js

In the browser environment, we don't use token directly, instead we use authcode to handle identity checks. You need to set an authcode in your cf-worker that only you know, and then we use it when initializing the notabase instance.

Env authCode Read Write Note
browser public data just read public data without authCode
browser private data you can read and modify private data with authCode
import Notabase from 'notabase'

// browser env
// without authCode Read public data
// with authCode CRUD support
let nb = new Notabase({
  proxy: {
    url: "cloudflare worker url",
    authCode: "nobody knows it but you"

Browser Extension

import Notabase from 'notabase'

// browser extension env
// CRUD support without setting anything
let nb = new Notabase()


Fetch Data

Method Note
fetch fetch data from one table, but you can't query relation data
fetchAll fetch data from multiple tables, you can query relation data if relation table has been fetched
// fetch one table
let songs = await nb.fetch("")

// fetch all tables about music
// get my music data
let db = await nb.fetchAll({
  songs: "",
  albums: "",
  artists: ""


Data in Notion table will be mapped to JavaScript Array

// get all songs
let allSongs = db.songs.rows
// get song by index
let song = allSongs[0]

// get one song's title (base props)

// get artist's name of the song (related props)
console.log(`${song.artist[0].Name}`) // a song maybe has two or more artists

// search song by title in song's table
let aSong = allSongs.find(song=> song.title === "Bad Guy")

// search all song by artist's name in song's table
let songByArtistName = allSongs.filter(song=> song.artist[0].name === "someone")
// search all song by artist's name in artist's table
songByArtistName = db.artists.rows.filter(a=> === "someone").songs


let aSong = allSongs.find(song=> song.title === "Bad Guy")
aSong.title = "new title"


// create then modify
let newRow = collection.addRow()
newRow.Tags = [tag1]

// create with value

Update Table Schema

// change
  value: "new tag",
  color: "pink"

// commit



  • collection.addRow({title:"",Tags:["tag1"]}) // add new row
  • updateSchema // update schema


  • row.delete() // delete a row
You can’t perform that action at this time.