API 參考文件

圖譜 API

圖譜 API 會傳回 Notion 工作空間的圖譜,包含節點(頁面、資料庫、使用者)及其相互關係(邊)。這是 IVGraph 3D 視覺化功能使用的主要端點。使用 Free 方案時,超過 500 個節點的工作空間會先完整顯示 5 分鐘,之後僅保留連結最多的 500 個節點(詳見下方)。

此 API 使用 IVGraph 登入驗證(JWT),不接受服務權杖(ivg_…):AI 代理程式須透過 Pro 和 Max 方案使用 V1 LLM API。

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
  }
}

圖譜超過方案節點上限時的回應:

付費方案(Plus、Pro、Max 及 Pro 週方案)仍會取得完整圖譜,並附上提示。Free 方案在首次開啟圖譜後的 5 分鐘內,會傳回完整圖譜(graph_preview.active 為 true);之後則僅傳回連結最多的 500 個節點及其間的連結。node_count 一律為節點總數。Free 方案超過上限時,回應也會包含 pro_week,也就是應用程式中顯示的 US$1.99 Pro 週方案優惠。

付費方案超過節點上限:

{
  "nodes": ["..."],
  "links": ["..."],
  "metadata": {},
  "stats": {},
  "node_limit_exceeded": true,
  "node_limit": 3000,
  "node_count": 3420,
  "nodes_shown": 3420,
  "node_limit_truncated": false
}

Free 方案,5 分鐘預覽結束後:

{
  "nodes": ["... 500 most connected nodes ..."],
  "links": ["... links between them ..."],
  "metadata": {},
  "stats": {},
  "node_limit_exceeded": true,
  "node_limit": 500,
  "node_count": 742,
  "nodes_shown": 500,
  "node_limit_truncated": true,
  "node_count_by_type": {"page": 690, "database": 40, "user": 12},
  "graph_preview": {"active": false, "started_at": "2026-10-27T09:00:00Z", "ends_at": "2026-10-27T09:05:00Z", "seconds_left": 0, "seconds": 300}
}

無連線時的回應:

{
  "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 資料庫的關聯屬性