How to get authentication information for Notion private API
Created
January 13, 2022
Tag
プロダクト
What is Notion private API?
- ENDPOINT: https://www.notion.so/api/v3
- It is not an officially announced 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
- Create a blank page in Notion
- Create inline table on that page
- 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
- Display the database you created above as a full page, and copy the URL of the page.
- 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 - Use the retrieved
Datebase ID
asBLOG_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
- Official API documentation: https://developers.notion.com/
- Do not use the full page table
- In the Notion desktop app, click
Share
in the upper right corner of the screen, and then clickCopy link
- The
Datebase ID
is 32 characters long, including numbers and letters
How to get NOTION_TOKEN
- Open Notion in your browser on any page
- Launch the Developer Tool
- Go to the
Application
tab >Storage
>Cookies
>token_v2
and copy theValue
- Use the retrieved
Value
asNOTION_TOKEN
- For Mac, use
Option + Command + I
- For Window, use
F12
orCtrl + Shift + I