圖譜 API
圖譜 API 可存取完整的 Notion 工作空間圖譜,包含所有節點(頁面、資料庫、使用者)及其相互關係(邊)。這是 IVGraph 3D 視覺化使用的主要端點。
GET /api/notion-graph/
傳回已通過身分驗證的使用者所屬工作空間的完整圖譜。
身分驗證: JWT(示範模式不需驗證)
參數:
| 參數 | 型別 | 必填 | 預設值 | 說明 |
|---|---|---|---|---|
| demo | string | 否 | — | 設為 true 以取得示範資料(不需驗證) |
| workspace_id | UUID | 否 | primary | 指定要載入的工作空間 |
| connection_id | UUID | 否 | — | 指定 Airbyte 連線 |
| admin_user | int | 否 | — | 覆寫使用者 ID(僅限工作人員) |
請求範例:
# Authenticated user's graph
curl -H "Authorization: Bearer <jwt_token>" \
"https://ivgraph.com/api/notion-graph/"
# Demo mode (no auth)
curl "https://ivgraph.com/api/notion-graph/?demo=true"
# Specific workspace
curl -H "Authorization: Bearer <jwt_token>" \
"https://ivgraph.com/api/notion-graph/?workspace_id=abc-123"
import requests
resp = requests.get(
"https://ivgraph.com/api/notion-graph/",
headers={"Authorization": "Bearer <jwt_token>"}
)
graph = resp.json()
print(f"{graph['stats']['nodes']} nodes, {graph['stats']['links']} edges")
const resp = await fetch("https://ivgraph.com/api/notion-graph/", {
headers: { Authorization: "Bearer <jwt_token>" }
});
const graph = await resp.json();
console.log(`${graph.stats.nodes} nodes, ${graph.stats.links} edges`);
回應:
{
"nodes": [
{
"id": "550e8400-e29b-41d4-a716-446655440001",
"type": "page",
"title": "Project Alpha",
"url": "https://www.notion.so/Project-Alpha-550e8400...",
"icon": {"type": "emoji", "emoji": "\ud83d\ude80"},
"connections_in": 5,
"connections_out": 12,
"connections_total": 17,
"pagerank": 0.42
}
],
"links": [
{
"id": "edge-uuid",
"source": "550e8400-e29b-41d4-a716-446655440001",
"target": "550e8400-e29b-41d4-a716-446655440002",
"type": "reference"
}
],
"metadata": {
"generated_at": "2026-04-10T12:00:00Z",
"user": "username",
"connection_id": "conn-uuid",
"sync_time": "2026-04-10T10:00:00Z"
},
"stats": {
"nodes": 342,
"links": 1205,
"total_blocks": 4500
}
}
超過訂閱方案節點上限時的回應(僅供提示,仍會傳回圖譜):
{
"nodes": ["..."],
"links": ["..."],
"metadata": {},
"stats": {},
"node_limit_exceeded": true,
"node_limit": 500,
"node_count": 742
}
沒有連線時的回應:
{
"nodes": [],
"links": [],
"metadata": {"status": "no_connection"},
"stats": {"nodes": 0, "links": 0, "total_blocks": 0}
}
資料結構定義
節點
| 欄位 | 型別 | 說明 |
|---|---|---|
| id | UUID | Notion 頁面/資料庫/使用者 ID |
| type | string | page、database 或 user |
| title | string | 頁面標題或資料庫名稱 |
| url | string | Notion 網址 |
| icon | object|null | 圖示資料(詳見下方) |
| connections_in | int | 連入邊數 |
| connections_out | int | 連出邊數 |
| connections_total | int | 邊的總數 |
| pagerank | float | PageRank 分數(0.0 — 1.0) |
圖示
| 欄位 | 型別 | 說明 |
|---|---|---|
| type | string | emoji、file 或 external |
| emoji | string | 表情符號字元(當 type=emoji 時) |
| file.url | string | 檔案網址(當 type=file 時) |
| external.url | string | 外部網址(當 type=external 時) |
邊
| 欄位 | 型別 | 說明 |
|---|---|---|
| id | UUID | 邊的識別碼 |
| source | UUID | 來源節點 ID |
| target | UUID | 目標節點 ID |
| type | string | reference、parent、mention 或 relation |
邊的類型
| 類型 | 說明 |
|---|---|
reference |
頁面連結至另一個頁面 |
parent |
頁面是資料庫或另一個頁面的子頁面 |
mention |
頁面提及另一個頁面或使用者 |
relation |
資料庫的關聯屬性 |