---
title: "Read a renderable subgraph of a collection's knowledge graph."
method: GET
path: "/graph/{collection_id}"
tags: ["GraphRAG"]
---

# Read a renderable subgraph of a collection's knowledge graph.

`GET /graph/{collection_id}`

## Request

- Base URL: `https://h2ogpte.genai.h2o.ai/api/v1`
- URL: `https://h2ogpte.genai.h2o.ai/api/v1/graph/{collection_id}`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/h2o/apis/h2ogpte-rest-api/docs/graph/:collection_id/get.ts> (a function with typed inputs; its response is checked against the schema)

Returns nodes and edges of the knowledge graph for visualization
(issue #11529). With label "*" (the default) returns the whole-graph
view, degree-ranked and capped at max_nodes with is_truncated set;
with a specific entity name returns the BFS neighborhood around that
node (used by the viewer's expand-on-click). Read-only; node ids
(entity names) and edge (source, target) pairs are the stable
addresses a future edit API will target.

## Path parameters

- `collection_id` string, uuid, required

## Query parameters

- `label` string
- `max_depth` integer
- `max_nodes` integer

## Response `200`

Successful operation

- KnowledgeGraphData: A renderable subgraph of a collection's knowledge graph (issue
  - `nodes` KnowledgeGraphVizNode[], required
    - `id` string, required: The entity name -- the graph's stable primary key for the node, and the address a future edit API mutates.
    - `entity_type` string: Extracted entity type (e.g. organization, person). Empty if unknown.
    - `description` string: LLM-extracted description of the entity, as newline-joined text. The graph store keeps one fragment per contributing source chunk; description_parts exposes them individually.
    - `description_parts` string[]: The entity's description fragments, one per contributing source chunk (the store's internal separator is not exposed).
    - `source_chunk_count` integer: How many source chunks contributed to this node.
    - `file_paths` string[]: Deduplicated source document filenames that contributed to this node.
    - `created_at` unknown
  - `edges` KnowledgeGraphVizEdge[], required
    - `id` string: Render key (order-normalized "src-tgt").
    - `source` string, required: Entity name of one endpoint.
    - `target` string, required: Entity name of the other endpoint.
    - `description` string: LLM-extracted description of the relationship, as newline-joined text. See description_parts for the per-chunk fragments.
    - `description_parts` string[]: The relationship's description fragments, one per contributing source chunk.
    - `keywords` string: Relationship keywords captured at extraction.
    - `weight` number, double, nullable: Relationship strength assigned at extraction.
    - `source_chunk_count` integer: How many source chunks contributed to this edge.
  - `is_truncated` boolean, required: True when the graph exceeded max_nodes and was degree-capped.
  - `total_nodes` integer, nullable: Total entities in the full graph (the nodes above are degree-ranked and capped at max_nodes). Null unless this is a truncated whole-graph view -- a focused subgraph or a complete (untruncated) graph carries no separate total.
  - `total_relationships` integer, nullable: Total relationships in the full graph. Null unless this is a truncated whole-graph view.

## Other responses

- `401`: Unauthorized - Invalid or missing API key
- `403`: Forbidden
- `404`: No knowledge graph exists for this collection.
- `default`: Unexpected error

---

[API](https://skmtc.dev/h2o/apis/h2ogpte-rest-api.md) - [All operations](https://skmtc.dev/h2o/apis/h2ogpte-rest-api/llms.txt) - [OpenAPI document](https://skmtc.dev/h2o/apis/h2ogpte-rest-api/revisions/a82a117320f4?raw)
