> ## Documentation Index
> Fetch the complete documentation index at: https://docs.snorbe.deskrex.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# グラフデータ取得

> ワークスペースのナレッジグラフデータ（ノード・エッジ）を取得します

# グラフデータ取得

指定したワークスペースのナレッジグラフデータを返します。UIの左側に表示される3Dグラフに相当するデータです。

## リクエスト

```
GET /api/v1/graph/workspace
```

### ヘッダー

| ヘッダー            | 必須 | 説明                             |
| --------------- | -- | ------------------------------ |
| `Authorization` | はい | `Bearer snorbe_...` 形式の API キー |

### クエリパラメータ

| パラメータ                   | 型         | 必須  | デフォルト   | 説明                  |
| ----------------------- | --------- | --- | ------- | ------------------- |
| `includeOthersEntities` | `boolean` | いいえ | `false` | 他のユーザーのエンティティを含めるか  |
| `nodeLimit`             | `integer` | いいえ | `50`    | 取得するノードの最大数（1〜500）  |
| `edgeLimit`             | `integer` | いいえ | `200`   | 取得するエッジの最大数（1〜1000） |

<Note>
  ワークスペースは API キーに紐づくものが自動的に使用されます。`workspaceId` パラメータは不要です。
</Note>

## レスポンス

```json theme={null}
{
  "nodes": [
    {
      "id": "clxxx001",
      "label": "リチウムイオン電池",
      "category": "technology",
      "kind": "entity",
      "description": "充電可能な二次電池の一種",
      "communityId": 3,
      "pagerank": 0.045,
      "x": 12.5,
      "y": -8.3,
      "z": 4.1
    }
  ],
  "edges": [
    {
      "id": "clyyy001",
      "source": "clxxx001",
      "target": "clxxx002",
      "type": "related_to",
      "weight": 0.85,
      "edgeType": "relationship"
    }
  ],
  "fetchedAt": "2026-04-16T10:30:00.000Z",
  "nodeCount": 50,
  "edgeCount": 120,
  "totalEntityCount": 342
}
```

### レスポンスフィールド

| フィールド                 | 型                | 説明                               |
| --------------------- | ---------------- | -------------------------------- |
| `nodes`               | `object[]`       | グラフノード（エンティティ）の配列                |
| `nodes[].id`          | `string`         | エンティティ ID                        |
| `nodes[].label`       | `string`         | エンティティ名                          |
| `nodes[].category`    | `string`         | カテゴリ（例: `technology`, `company`） |
| `nodes[].kind`        | `string`         | ノード種別（`entity`, `ghost`）         |
| `nodes[].description` | `string`         | エンティティの説明                        |
| `nodes[].communityId` | `number \| null` | コミュニティクラスタ ID                    |
| `nodes[].pagerank`    | `number`         | PageRank スコア                     |
| `nodes[].x`           | `number \| null` | X 座標（3D レイアウト）                   |
| `nodes[].y`           | `number \| null` | Y 座標（3D レイアウト）                   |
| `nodes[].z`           | `number \| null` | Z 座標（3D レイアウト）                   |
| `edges`               | `object[]`       | グラフエッジ（リレーション）の配列                |
| `edges[].id`          | `string`         | リレーション ID                        |
| `edges[].source`      | `string`         | 始点エンティティ ID                      |
| `edges[].target`      | `string`         | 終点エンティティ ID                      |
| `edges[].type`        | `string`         | リレーションタイプ                        |
| `edges[].weight`      | `number`         | エッジの重み（0〜1）                      |
| `edges[].edgeType`    | `string`         | エッジ種別（`relationship`）            |
| `fetchedAt`           | `string`         | 取得日時（ISO 8601）                   |
| `nodeCount`           | `number`         | 取得したノード数                         |
| `edgeCount`           | `number`         | 取得したエッジ数                         |
| `totalEntityCount`    | `number`         | ワークスペース内の全エンティティ数                |

## 使用例

<CodeGroup>
  ```bash cURL theme={null}
  curl "https://app.snorbe.deskrex.ai/api/v1/graph/workspace?nodeLimit=100&edgeLimit=500" \
    -H "Authorization: Bearer snorbe_your_api_key_here"
  ```

  ```python Python theme={null}
  import requests

  resp = requests.get(
      "https://app.snorbe.deskrex.ai/api/v1/graph/workspace",
      params={"nodeLimit": 100, "edgeLimit": 500},
      headers={"Authorization": "Bearer snorbe_your_api_key_here"},
  )
  data = resp.json()
  print(f"Nodes: {data['nodeCount']} / {data['totalEntityCount']}")
  print(f"Edges: {data['edgeCount']}")
  ```

  ```typescript TypeScript theme={null}
  const params = new URLSearchParams({ nodeLimit: "100", edgeLimit: "500" });
  const resp = await fetch(
    `https://app.snorbe.deskrex.ai/api/v1/graph/workspace?${params}`,
    { headers: { Authorization: "Bearer snorbe_your_api_key_here" } },
  );
  const data = await resp.json();
  console.log(`Nodes: ${data.nodeCount} / ${data.totalEntityCount}`);
  console.log(`Edges: ${data.edgeCount}`);
  ```
</CodeGroup>

## エラーレスポンス

| HTTP ステータス | コード                 | 説明                    |
| ---------- | ------------------- | --------------------- |
| 401        | `UNAUTHORIZED`      | API キーが無効、期限切れ、または未指定 |
| 429        | `TOO_MANY_REQUESTS` | レート制限超過               |
