2.4.1 • Published 4 years ago

get-notion-contents v2.4.1

Weekly downloads
43
License
MIT
Repository
github
Last release
4 years ago

get-notion-contents

Get contents from notion

NPM Build Status npm bundle size (minified)

Installation

$ npm i -S get-notion-contents

⚠️ Prerequisite

You need a token to use this package if you want to get private contents. You can get it from Notion.so cookie. the key of it is token_v2.

Development

$ export NOTION_TOKEN="<<YOUR_NOTION_TOKEN>>"
$ npm start

Return type of methods

getUser()

Promise<{
  email: string;
  family_name: string;
  given_name: string;
  id: string;
  onboarding_completed: boolean;
  profile_photo: string;
  version: number;
}>

getPageIds(skipChildren: boolean = false)

Promise<string[]>

getPageById(id: string)

Promise<{
  id: string;
  title: string;
  titleString: string;
  content: string;
  resource?: string;
}>

getPages()

Promise<Array<{
  id: string;
  title: string;
  titleString: string;
  content: string;
  resource?: string;
}>>

How to use

import Notion from 'get-notion-contents';

// create instance of Notion.
const notion = new Notion('<<YOUR_NOTION_TOKEN>>', { prefix: '<<PREFIX_OF_LINK>>', removeStyle: false });

(async () => {
  // get user information
  const user = await notion.getUser();
  console.log(user);

  // get ids of all pages
  const pageIds = await notion.getPageIds();
  console.log(pageIds);

  // get content of a page
  const page = await notion.getPageById(pageIds[0]);
  console.log(page);

  // get contents of all pages
  const pages = await notion.getPages();
  console.log(pages);
})();

Option

  • prefix: add prefix into relative links
  • removeStyle: remove inline styles

2.4.1

4 years ago

2.4.0

4 years ago

2.3.0

4 years ago

2.2.0

4 years ago

2.1.4

4 years ago

2.1.3

4 years ago

2.1.2

4 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.0.6

4 years ago

2.0.5

4 years ago

2.0.4

4 years ago

2.0.3

4 years ago

2.0.2

4 years ago

2.0.1

4 years ago

2.0.0

4 years ago

1.1.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago