Skip to content

Instantly share code, notes, and snippets.

@GitMurf
Created January 11, 2022 00:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GitMurf/e84a8f9aeeff03c393757afee04efb3e to your computer and use it in GitHub Desktop.
Save GitMurf/e84a8f9aeeff03c393757afee04efb3e to your computer and use it in GitHub Desktop.
This is a POC test to connecting to the Notion API from Obsidian
<%*
const notionApiKey = 'YOUR_API_KEY_SEE_COMMENTS_FOR_HOW_TO_GET';
const reqParams = {
url: 'https://api.notion.com/v1/databases',
method: 'GET',
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${notionApiKey}`,
"Notion-Version": `2021-08-16`,
},
}
let requestResults = await window.request(reqParams);
let dataResults = JSON.parse(requestResults);
let finalResult = dataResults.results[0].title[0].plain_text;
tR = `Page Name: ${finalResult}`;
%>
@GitMurf
Copy link
Author

GitMurf commented Jan 11, 2022

To get your API Key, follow this guide here: https://developers.notion.com/docs#step-1-create-an-integration

Just need to follow steps 1 and 2 in that guide. I also screen-shotted the instructions from that guide below:

image

image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment