Files
Brancheneinstufung2/company-explorer/backend/scripts/notion_tools/read_notion_dashboard.py
Floke d021b6b71c refactor: [30388f42] Strukturiere Root-Skripte thematisch neu
- Organisiert eine Vielzahl von Skripten aus dem Root-Verzeichnis in thematische Unterordner, um die Übersichtlichkeit zu verbessern und die Migration vorzubereiten.
- Verschiebt SuperOffice-bezogene Test- und Hilfsskripte in .
- Verschiebt Notion-bezogene Synchronisations- und Import-Skripte in .
- Archiviert eindeutig veraltete und ungenutzte Skripte in .
- Die zentralen Helfer  und  bleiben im Root, da sie von mehreren Tools als Abhängigkeit genutzt werden.
2026-03-06 10:16:08 +00:00

42 lines
1.1 KiB
Python

import os
import requests
import json
# Get the Notion API key from the environment variable
api_key = os.environ.get("NOTION_API_KEY")
# If the API key is not set, try to read it from the file
if not api_key:
try:
with open("notion_token.txt", "r") as f:
api_key = f.read().strip()
except FileNotFoundError:
print("Error: notion_token.txt not found.")
print("Please set the NOTION_API_KEY environment variable or create the notion_token.txt file.")
exit()
# The ID of the page to retrieve
page_id = "2e288f42-8544-81d8-96f5-c231f84f719a" # Product Master
# The Notion API endpoint for retrieving a page
url = f"https://api.notion.com/v1/pages/{page_id}"
# The headers for the API request
headers = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json",
"Notion-Version": "2022-06-28",
}
# Make the API request
response = requests.get(url, headers=headers)
# Check the response status code
if response.status_code == 200:
# Print the response content
print(json.dumps(response.json(), indent=2))
else:
print(f"Error: {response.status_code}")
print(response.text)