Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/narkdown/notion-parser
Parse Notion API response
https://github.com/narkdown/notion-parser
Last synced: 3 months ago
JSON representation
Parse Notion API response
- Host: GitHub
- URL: https://github.com/narkdown/notion-parser
- Owner: narkdown
- License: mit
- Created: 2021-11-10T15:12:02.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2021-11-26T12:43:30.000Z (almost 3 years ago)
- Last Synced: 2024-07-01T04:26:50.193Z (4 months ago)
- Language: TypeScript
- Homepage:
- Size: 373 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# @narkdown/notion-parser
> Generate massive amounts of fake contextual data for Notion
[![codecov](https://codecov.io/gh/narkdown/notion-parser/branch/main/graph/badge.svg)](https://codecov.io/gh/narkdown/notion-parser)
[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo)
[![npm version](https://badge.fury.io/js/@narkdown%2Fnotion-parser.svg)](https://badge.fury.io/js/@narkdown%2Fnotion-parser)
[![license: MIT](https://img.shields.io/badge/license-MIT-green.svg)](./LICENSE)## Install
```
$ npm install @narkdown/notion-parser
```## Usage
```typescript
const {Client} = require('@notionhq/client');
const {NotionParser} = require('@narkdown/notion-parser');const NOTION_API_KEY = ''; // Notion API Key
const DATABASE_ID = ''; // Database IDconst notion = new Client({auth: NOTION_API_KEY});
const notionParser = new NotionParser({
propertyOptions: {
date: {
timeZone: 'Asia/Seoul',
format: 'yyyy-MM-dd HH:mm:ss',
},
},
});const {results} = await notion.databases.query({
database_id: DATABASE_ID,
});const rows = notionParser.database.getRows(results);
console.log(rows);
```## API
### `const notionParser = new NotionParser(options?)`
#### options
Type: `object`
##### propertyOptions
Type: `object`
###### date
- `timeZone` (`string`): [time zone name](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) (Default: `Asia/Seoul`)
- `format` (`string`) : [Date format patterns](https://www.unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table) (Default: `yyyy-MM-dd HH:mm:ss`)#### `notionParser.database.getRows(results)`
##### results
results field of [Query a database response](https://developers.notion.com/reference/post-database-query)
## Support
### [Database Object](https://developers.notion.com/reference/database)
| Property | Supported |
| ------------------ | --------- |
| `object` | ❌ |
| `id` | ❌ |
| `created_time` | ❌ |
| `last_edited_time` | ❌ |
| `title` | ❌ |
| `icon` | ❌ |
| `cover` | ❌ |
| `properties` | ⚠️ |
| `parent` | ❌ |
| `url` | ❌ |#### Property Object
| Property | Supported |
| ------------------ | --------- |
| `title` | ✅ |
| `rich_text` | ✅ |
| `number` | ✅ |
| `select` | ✅ |
| `multi_select` | ✅ |
| `date` | ✅ |
| `files` | ❌ |
| `checkbox` | ✅ |
| `url` | ✅ |
| `email` | ✅ |
| `phone_number` | ✅ |
| `formula` | ❌ |
| `relation` | ❌ |
| `rollup` | ❌ |
| `people` | ❌ |
| `created_by` | ❌ |
| `created_time` | ✅ |
| `last_edited_by` | ❌ |
| `last_edited_time` | ✅ |### [Page Object](https://developers.notion.com/reference/page)
| Property | Supported |
| ------------------ | --------- |
| `object` | ❌ |
| `id` | ❌ |
| `created_time` | ❌ |
| `last_edited_time` | ❌ |
| `archived` | ❌ |
| `icon` | ❌ |
| `cover` | ❌ |
| `properties` | ❌ |
| `parent` | ❌ |
| `url` | ❌ |## Related
- [makenotion/notion-sdk-js](https://github.com/makenotion/notion-sdk-js)
## License
[MIT](LICENSE)