37 lines
924 B
Python
37 lines
924 B
Python
|
|
import requests
|
|
import json
|
|
|
|
# Notion Config
|
|
try:
|
|
with open("notion_token.txt", "r") as f:
|
|
NOTION_TOKEN = f.read().strip()
|
|
except FileNotFoundError:
|
|
print("Error: notion_token.txt not found.")
|
|
exit(1)
|
|
|
|
NOTION_VERSION = "2022-06-28"
|
|
NOTION_API_BASE_URL = "https://api.notion.com/v1"
|
|
HEADERS = {
|
|
"Authorization": f"Bearer {NOTION_TOKEN}",
|
|
"Notion-Version": NOTION_VERSION,
|
|
"Content-Type": "application/json",
|
|
}
|
|
|
|
# DB ID from import_product.py
|
|
DB_ID = "2e288f42-8544-8113-b878-ec99c8a02a6b"
|
|
|
|
def get_db_properties(database_id):
|
|
url = f"{NOTION_API_BASE_URL}/databases/{database_id}"
|
|
try:
|
|
response = requests.get(url, headers=HEADERS)
|
|
response.raise_for_status()
|
|
return response.json().get("properties")
|
|
except Exception as e:
|
|
print(f"Error: {e}")
|
|
return None
|
|
|
|
props = get_db_properties(DB_ID)
|
|
if props:
|
|
print(json.dumps(props, indent=2))
|