如何使用 notions api 检索站点?

Bla*_*man 2 javascript node.js notion-api

我目前正在尝试使用 notions API 下载网站/页面。我分享了该页面并尝试了以下操作:

(async () => {

    const pageId = 'abcd-editorial-efe.notion.site/Sites-abc123';
  
    const response = await notion.pages.retrieve({ page_id: pageId });
  
    console.log(response);
  
  })();
Run Code Online (Sandbox Code Playgroud)

我收到一条错误消息:

@notionhq/client warn: request fail {
  code: 'object_not_found',
  message: 'Could not find page with ID: abc123..... Make sure the relevant pages and databases are shared with your integration.'
}
Run Code Online (Sandbox Code Playgroud)

这是检索页面的正确 API 端点吗?

Notions docs pageId 是一个 GUID...但是当我共享我的页面时,我得到了一个完整的 URL:

(async () => {

  const pageId = 'b55c9c91-384d-452b-81db-d1ef79372b75';

  const response = await notion.pages.retrieve({ page_id: pageId });

  console.log(response);

})();
Run Code Online (Sandbox Code Playgroud)

我在用 "@notionhq/client": "^1.0.4"

Jak*_*ke 6

2022 年 11 月之前

您过去必须邀请像Muhammad Magdi在评论中提到的集成:

share“部分”(右上角)中,选择invite并邀请您的集成。

2022 年 11 月之后

正如下面的 [umihico] 所说,在最新版本的 Notion 中,您可以从右上角的“三点”菜单中“添加连接”。

  • 今天我必须使用右上角三点菜单中的“添加连接”。似乎不再邀请集成等非人类帐户 (3认同)