概念 - 查询数据库和页面提供有限的属性
Notion - Querying databases and pages provide limited properties
我正在尝试通过 REST API.
访问我的概念中的单个数据库
在 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)
正在呼叫 list_db。可以看到检索到的属性数是16
正在呼叫 query_db。您可以看到为第一页检索到的属性数是 14
此屏幕截图显示了我的数据库的属性列表
在概念中显示数据库属性的最终屏幕截图有 6 个箭头 。这 6 个属性代表指向数据库的关系属性。
- 相关项目
- 购物清单
- 依赖于(任务)
- 相关People/Company
- 资源
- 子任务
其中 2 个关系属性是自身关系,这意味着它们指向它们所在的同一个数据库。
- 子任务
- 依赖于(任务)
对概念 REST API 的调用只能访问您授予权限的数据库。由于您只提供了对这个单一数据库的访问权限,因此您应该只能看到自身关系属性。
放大镜代表公式属性。如果任何公式 属性 使用您的概念 API 集成无法访问的关系 属性,那么您也将无法看到它们。
- 项目状态
- 购买状态
- 费用
在数据库中查询页面时,您可能只会收到页面具有非空值的属性。
我正在尝试通过 REST API.
访问我的概念中的单个数据库在 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)
正在呼叫 list_db。可以看到检索到的属性数是16
正在呼叫 query_db。您可以看到为第一页检索到的属性数是 14
此屏幕截图显示了我的数据库的属性列表
在概念中显示数据库属性的最终屏幕截图有 6 个箭头
- 相关项目
- 购物清单
- 依赖于(任务)
- 相关People/Company
- 资源
- 子任务
其中 2 个关系属性是自身关系,这意味着它们指向它们所在的同一个数据库。
- 子任务
- 依赖于(任务)
对概念 REST API 的调用只能访问您授予权限的数据库。由于您只提供了对这个单一数据库的访问权限,因此您应该只能看到自身关系属性。
放大镜
- 项目状态
- 购买状态
- 费用
在数据库中查询页面时,您可能只会收到页面具有非空值的属性。