![npm]( ![npm bundle size](
Last updated 2 months ago by cstrnt .
ISC · Repository · Original npm · Tarball · package.json
$ cnpm install notion-api-js 
SYNC missed versions from official npm registry.

Unofficial Wrapper (WIP)

npm npm bundle size

This Repository contains an unofficial port of the Notion to Node.js. Important: It only works using Node.js in backend and not in a client-side environment.

IMPORTANT: You need a token to use the Notion API. You can obtain them by reading you local cookie. You can find instructions for that



You can either use npm or yarn to install it:

npm i --save notion-api-js
yarn add notion-api-js


Creating an instance

To create an instance, simply pass an Object with your notion token_v2.

// ES Modules syntax
import Notion from "notion-api-js";

// require syntax
const Notion = require("notion-api-js").default;

const notion = new Notion({
  token: "YOUR_TOKEN_V2"

You can also provide options for the HTML parsing.

const notion = new Notion({
  token: "YOUR_TOKEN_V2",
  options: {
    colors: {
      orange: 'CSS COLOR HERE'
    pageUrl: 'ABSOLUTE PAGE URL (e.g. /posts/'),

Obtaining Credentials

Right now there is no official way how to access the Notion API, but there is a little work-around to get your credentials.


You need to have an Account on and need to be logged in.

Getting your credentials

Most of the modern web browsers support inspecting cookies visually using the browser's devtools. You can read how to do it in your browser here:

After you found the cookie, look for token_v2. It is the necessary credential for the Notion instance. Simply copy them when you create the instance

Instance Options

The Options are optionally passed to the instance as a parameter. Those options contain information on how the HTML will be parsed and returned using the instance methods.

Colors (Object)

Contains definitions for the colors. If this option is omitted the default html colors like orange, pink and blue are used. You can change this behaviour by passing an object containing colour definitions. Example:

options: {
    colors: {
      red: 'tomato',
      blue: 'rgb(100, 149, 237)',
      purple: '#9933cc',

Possible colors are:

  • red
  • brown
  • orange
  • yellow
  • teal
  • blue
  • purple
  • pink

PageUrl (String)

The PageUrl is the string passed to the <a> tag and is used to build the href of it. The id is inserted after the passed string. By default it looks like this /page?id=, which results into <a href="/page?id=SOME_ID">Hello World</a>

Instance Methods


Gets all pages of the user by the userId passed to the Notion instance. All pages are parsed to HTML.


notion.getPages().then(pages => {
  // Your Code here


Gets a Notion page by the pageId and returns it parsed to HTML.


Parameter Type Opt/Required
pageId string Required


notion.getPageById("pageID").then(page => {
  // Your Code here


Gets a Notion page by the given Id and all subpages of that page. Useful if you want to use a homepage.


Parameter Type Opt/Required
pageId string Required


notion.getPagesByIndexId("pageID").then(page => {
  // Your Code here

getAllHTML() [WIP]

Gets the HTML for all pages.

notion.getAllHTML().then(html => {
  // Your Code here


It's really WIP right now but I would highly appreciate if you would like to contribute to the project. Just fork this repo and create a PR ????

Current Tags

  • 2.3.0                                ...           latest (2 months ago)

13 Versions

  • 2.3.0                                ...           2 months ago
  • 2.2.2                                ...           2 months ago
  • 2.2.1                                ...           2 months ago
  • 2.2.0                                ...           2 months ago
  • 2.1.0                                ...           6 months ago
  • 2.0.0                                ...           6 months ago
  • 1.5.0                                ...           9 months ago
  • 1.4.0                                ...           9 months ago
  • 1.3.0                                ...           9 months ago
  • 1.2.0                                ...           9 months ago
  • 1.1.1                                ...           9 months ago
  • 1.1.0                                ...           9 months ago
  • 1.0.0                                ...           9 months ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (2)
Dependents (0)

Copyright 2014 - 2017 © |