ヘッダー画像
前島 悠人
cover image

How to get authentication information for Notion private API

Created
January 13, 2022
Tag
プロダクト

What is Notion private API?

Authentication information for the Notion private API

The following two pieces of information are required.

  • The id of the table itself of the article you want to display: BLOG_INDEX_ID.
  • The token of the Notion login: NOTION_TOKEN.

Both of them are a little complicated to get, but they are explained in detail below.

How to get BLOG_INDEX_ID

1. Create a Blog Table

  1. Create a blank page in Notion
  2. Create inline table on that page
  3. Add the following fields to the table

Fields to add.

  • Page (Title): Title of the article page.
  • Slug (Text): URL of the blog post page.
  • Published (Checkbox): Filter if the post should be published to production or not.
  • Date (Date): The date the article was published.

2. Get BLOG_INDEX_ID

  1. Display the database you created above as a full page, and copy the URL of the page.
  2. The URL is structured as follows, and the string between the question mark (?) and the slash of your workspace name (myworkspace/ in the example below) is the Database ID
  3. Use the retrieved Datebase ID as BLOG_INDEX_ID.
<https://www.notion.so/myworkspace/a8aec43384f447ed84390e8e42c2e089?v=>...
                                  |--------- Database ID --------|

Ref: https://developers.notion.com/docs/getting-started#step-2-share-a-database-with-your-integration

An image from Notion
  • In the Notion desktop app, click Share in the upper right corner of the screen, and then click Copy link
  • The Datebase ID is 32 characters long, including numbers and letters

How to get NOTION_TOKEN

  1. Open Notion in your browser on any page
  2. Launch the Developer Tool
  3. Go to the Application tab > Storage > Cookies > token_v2 and copy the Value
  4. Use the retrieved Value as NOTION_TOKEN
  • For Mac, use Option + Command + I
  • For Window, use F12 or Ctrl + Shift + I
An image from Notion