- Implement relational data structure in Notion as per the plan. - Add scripts for initial data import (import_product.py) and distribution to related databases (distribute_product_data.py). - Create helper scripts for reading Notion content. - Update Notion_Dashboard.md and GEMINI.md with the latest implementation status, database IDs, and key lessons learned from the MVP phase, including API constraints and schema-first principles.
42 lines
1.1 KiB
Python
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)
|