我正在尝试通过 REST API 访问我的 Notion 中的单个数据库。
在 Notion 中查询或列出我的数据库时,我仅收到预期属性的子集。
正如您在最后一个屏幕截图中看到的那样,我访问的数据库中有 23 个属性。
因此,有 7 个未显示,因为当我调用 LIST DB REST API 时看到 16 个(第一个屏幕截图)。知道为什么这 7 个属性没有显示吗?
class Test:
def __init__(self):
self.notion = None
self.databases = {}
self.pageIds = []
self.pages = {}
def initialize(self):
#NOTION_TOKEN = os.getenv("NOTION_TOKEN", "")
with open('Notion_Config.YAML') as f:
data = yaml.load(f, Loader=yaml.FullLoader)
print(data)
NOTION_TOKEN = data["Token"]
while NOTION_TOKEN == "":
print("NOTION_TOKEN not found.")
NOTION_TOKEN = input("Enter your integration token: ").strip()
self.notion = Client(auth=NOTION_TOKEN)
def list_db(self):
results = self.notion.databases.list()
print("Listing databases: ")
for item in results["results"]:
print(item["title"][0]["plain_text"])
self.databases.update({item["title"][0]["plain_text"] : item["id"]})
def query_db(self, database_name):
#while db["more"] == True:
db = self.notion.databases.query(database_id=self.databases.get(database_name))
for item in db["results"]:
print(item)
self.pageIds.append(item["id"])
def query_pages(self):
for item in self.pageIds:
page = self.notion.pages.retrieve(page_id=item)
print(page)
Calling list_db. You can see the number of properties retrieved is 16
Calling query_db. You can see the number of properties retrieved for this first page is 14
此屏幕截图显示了我的数据库的属性列表
The final screenshot which shows the properties of the database in notion has 6 arrows . These 6 properties represent relational properties which point to a database.
- 相关项目
- 购物清单
- 依赖于(任务)
- 相关人士/公司
- 资源
- 子任务
其中 2 个关系属性是自关系,这意味着它们指向它们所在的同一个数据库。
对 Notion REST API 的调用只能访问您已授予权限的数据库。由于您只提供了对这个单一数据库的访问,因此您应该只看到自关系属性。
The magnifying glasses represent formula properties. If any formula property uses a relation property that your Notion API integration doesnt have access to, then you will also not be able to see those either.
在数据库中查询页面时,您可能只会收到该页面具有非空值的属性。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)