APIリファレンス

グラフ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のURLです
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 ファイルのURLです(type=fileの場合)
external.url string 外部URLです(type=externalの場合)

エッジ

フィールド 型 説明
id UUID エッジの識別子です
source UUID 接続元ノードのIDです
target UUID 接続先ノードのIDです
type string reference、parent、mention、またはrelationです

エッジの種類

種類 説明
reference ページから別のページへのリンクです
parent ページがデータベースまたはページの子ページであることを示します
mention ページ内での別のページやユーザーへのメンションです
relation データベースのリレーションプロパティです