get-notion-contents
Get contents from notion
Installation
$ npm i -S get-notion-contents
⚠️ Prerequisite
You need a token to use this package.
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()
Promise<string[]>
getPageById(id: string)
Promise<{
title: string;
content: string;
resource?: string;
}>
getPages()
Promise<Array<{
title: string;
content: string;
resource?: string;
}>>
How to use
import Notion from 'get-notion-contents';
const notion = new Notion('<<YOUR_NOTION_TOKEN>>');
(async () => {
const user = await notion.getUser();
console.log(user);
const pageIds = await notion.getPageIds();
console.log(pageIds);
const page = await notion.getPageById(pageIds[0]);
console.log(page);
const pages = await notion.getPages();
console.log(pages);
})();