I need help finding the database ID of a child database that’s embedded within a Notion page.
I’ve been using the Notion API to fetch the parent page data with a GET request. Here’s my current approach:
import requests
import json
# My Notion API token
TOKEN = "secret_ApiToken_123"
# Target page endpoint
api_endpoint = "https://api.notion.com/v1/pages/main_page_id_here"
# Request headers
request_headers = {
"Authorization": f"Bearer {TOKEN}",
"Content-Type": "application/json",
"Notion-Version": "2022-06-28",
}
# Execute the request
api_response = requests.get(api_endpoint, headers=request_headers)
# Process response data
if api_response.status_code == 200:
page_data = api_response.json()
with open("page_output.json", "w") as output_file:
json.dump(page_data, output_file)
else:
print(f"Request failed with status: {api_response.status_code}")
The response I get looks like this:
{
"object": "page",
"id": "main_page_id",
"created_time": "2023-09-14T02:02:00.000Z",
"last_edited_time": "2023-09-14T10:53:00.000Z",
"created_by": {
"object": "user",
"id": "user_id_here"
},
"last_edited_by": {
"object": "user",
"id": "editor_id"
},
"cover": null,
"icon": { "type": "emoji", "emoji": "🔬" },
"archived": false,
"properties": {
"title": {
"id": "title",
"type": "title",
"title": [
{
"type": "text",
"text": { "content": "Testing Zone", "link": null },
"annotations": {
"bold": false,
"italic": false,
"strikethrough": false,
"underline": false,
"code": false,
"color": "default"
},
"plain_text": "Testing Zone",
"href": null
}
]
}
},
"url": "https://www.notion.so/Testing-Zone-main_page_id",
"public_url": null
}
I don’t see any field that contains information about child databases or blocks. Is there a different API endpoint or method I should use to access the embedded database IDs within a page?