Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wonism/get-notion-contents
Get contents from notion
https://github.com/wonism/get-notion-contents
notion notion-contents
Last synced: about 1 month ago
JSON representation
Get contents from notion
- Host: GitHub
- URL: https://github.com/wonism/get-notion-contents
- Owner: wonism
- Created: 2019-12-15T15:42:14.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2022-06-25T09:42:15.000Z (over 2 years ago)
- Last Synced: 2024-10-14T06:52:18.338Z (2 months ago)
- Topics: notion, notion-contents
- Language: TypeScript
- Homepage:
- Size: 499 KB
- Stars: 10
- Watchers: 3
- Forks: 1
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# get-notion-contents
> Get contents from notion[![NPM](https://img.shields.io/npm/v/get-notion-contents.svg?style=flat)](https://npmjs.org/package/get-notion-contents)
[![Build Status](https://travis-ci.org/wonism/get-notion-contents.svg?branch=master)](https://travis-ci.org/wonism/get-notion-contents)
![npm bundle size (minified)](https://img.shields.io/bundlephobia/min/get-notion-contents.svg)## Installation
```sh
$ 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](https://www.notion.so/) cookie. the key of it is `token_v2`.## Development
```sh
$ export NOTION_TOKEN="<>"
$ npm start
```## Return type of methods
#### getUser()
```ts
Promise<{
email: string;
family_name: string;
given_name: string;
id: string;
onboarding_completed: boolean;
profile_photo: string;
version: number;
}>
```#### getPageIds(skipChildren: boolean = false)
```ts
Promise
```#### getPageById(id: string)
```ts
Promise<{
id: string;
title: string;
titleString: string;
content: string;
resource?: string;
}>
```#### getPages()
```ts
Promise>
```## How to use
```ts
import Notion from 'get-notion-contents';// create instance of Notion.
const notion = new Notion('<>', { prefix: '<>', 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---