Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/rudifa/notion-api-example

Learning Notion API access
https://github.com/rudifa/notion-api-example

Last synced: 24 days ago
JSON representation

Learning Notion API access

Awesome Lists containing this project

README

        

# Notion API access

Demo based on [Getting started with the Notion API JavaScript SDK](https://dev.to/craigaholliday/getting-started-with-the-notion-api-javascript-sdk-c50)

Uses `@notionhq/client`.

## Notion setup

In the target Notion workspace - Settings - Connections - Develop and manage integrations:

- create a new Integration, give it a name
- copy the `Internal Integration Token` to the local file .env

In the target Notion workspace - target page:

- ... menu - Connections: add a connection to the named Integration
- Share - Copy link: copy the url link and paste into a text editor
- extract the first 32-character `UUID` and pste it into the local .env file

## Setup

Requires a file named `.env` in the project directory, containing the keys from Notion

```
NOTION_API_KEY=secret_n3w...iZWq # 56 chars `Internal Integration Token`
NOTION_API_DATABASE=ef7...b44 # 32 chars `UUID`
```

## Run

```
npm start
```

Prints the received json to the stdout console.

## Notes

This script uses `@notionhq/client`.

## Issues

The retrieved JSON data contains some `[Object]` items.

```
description: [
{
type: 'text',
text: [Object],
annotations: [Object],
```

Open question: is this generated by the Notion API, or by processing in the `@notionhq/client`?

A similar go program retrieves valid JSON from the same API.