I am trying to access a single database in my Notion via the REST API.
When querying or listing my database in Notion, I only receive a subset of the expected properties.
There are 23 properties in my accessed database as you can see in the last screenshot. So there are 7 that are not showing up since I am seeing 16 when I call the LIST DB REST API (1st screenshot). Any idea why these 7 properties are not showing up?
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
This screenshot shows the list of properties for my database