> For clean Markdown of any page, append .md to the page URL. > For a complete documentation index, see https://docs-beta.getzep.com/v4/how-to-find-facts-relevant-to-a-specific-node/llms.txt. > For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs-beta.getzep.com/_mcp/server. # Find Facts Relevant to a Specific Node Below, we will go through how to retrieve facts which are related to a specific node in a Zep knowledge graph. First, we will go through some methods for determining the UUID of the node you are interested in. Then, we will go through some methods for retrieving the facts related to that node. The examples use the UUIDs that Zep returns when you create a user: `zep_user_uuid` is the user UUID, and `zep_graph_uuid` is the `graph_uuid` of the user graph. Store both UUIDs in your database next to your own user ID. ## Find the node's UUID Use the [`user.get_node`](/user-summary#retrieval) method to retrieve the user's node and its UUID. An easy way to determine the UUID for other nodes is to use the graph explorer in the [Zep Web app](https://app.getzep.com/). You can also programmatically [list the nodes](/reading-data-from-the-graph#listing-nodes) of a graph, and then manually examine the nodes and take note of the UUID of the node of interest: **`Python`** ```python Python from zep_cloud.client import Zep # Initialize the Zep client zep_client = Zep(api_key=API_KEY) nodes = zep_client.graph.node.list(zep_graph_uuid) for node in nodes: print(node.uuid_, node.name) ``` **`TypeScript`** ```typescript TypeScript import { ZepClient } from "@getzep/zep-cloud"; // Initialize the Zep client const client = new ZepClient({ apiKey: API_KEY }); const nodes = await client.graph.node.list(zepGraphUuid, { body: {} }); for await (const node of nodes) { console.log(node.uuid, node.name); } ``` **`Go`** ```go Go import ( "context" "fmt" "log" "github.com/getzep/zep-go/v4/client" "github.com/getzep/zep-go/v4/graph" "github.com/getzep/zep-go/v4/option" ) // Initialize the Zep client zepClient := client.NewClient(option.WithAPIKey(API_KEY)) nodes, err := zepClient.Graph.Node.List( context.TODO(), zepGraphUUID, &graph.NodeListRequest{}, ) if err != nil { log.Fatalf("Error: %v", err) } iterator := nodes.Iterator() for iterator.Next(context.TODO()) { node := iterator.Current() fmt.Println(*node.UUID, *node.Name) } if err := iterator.Err(); err != nil { log.Fatalf("Error: %v", err) } ``` **`Python`** ```python Python center_node_uuid = "your chosen center node UUID" ``` **`TypeScript`** ```typescript TypeScript const centerNodeUuid = "your chosen center node UUID"; ``` **`Go`** ```go Go centerNodeUUID := "your chosen center node UUID" ``` Lastly, if your user has a lot of nodes to look through, you can narrow down the search by only looking at the nodes relevant to a specific query, using [node search](/searching-the-graph#nodes): **`Python`** ```python Python results = zep_client.graph.search_nodes( zep_graph_uuid, query="shoe", # To help narrow down the nodes you have to manually search ) relevant_nodes = results.items or [] print(relevant_nodes) ``` **`TypeScript`** ```typescript TypeScript const results = await client.graph.searchNodes(zepGraphUuid, { body: { query: "shoe", // To help narrow down the nodes you have to manually search }, }); const relevantNodes = results.data; console.log(relevantNodes); ``` **`Go`** ```go Go import ( zep "github.com/getzep/zep-go/v4" ) results, err := zepClient.Graph.SearchNodes( context.TODO(), zepGraphUUID, &zep.GraphSearchNodesRequest{ Body: &zep.SearchRequest{ Query: "shoe", // To help narrow down the nodes you have to manually search }, }, ) if err != nil { log.Fatalf("Error: %v", err) } relevantNodes := results.Results fmt.Println(relevantNodes) ``` **`Python`** ```python Python center_node_uuid = "your chosen center node UUID" ``` **`TypeScript`** ```typescript TypeScript const centerNodeUuid = "your chosen center node UUID"; ``` **`Go`** ```go Go centerNodeUUID := "your chosen center node UUID" ``` ## Retrieve facts related to the node Use [edge listing](/reading-data-from-the-graph#listing-edges-with-filters) with the `connected_node_uuids` filter to retrieve only the facts connected to your chosen node. The server applies the filter, so you don't fetch and discard every other edge in the graph: **`Python`** ```python Python edges = zep_client.graph.edge.list( zep_graph_uuid, filters={"connected_node_uuids": [center_node_uuid]}, ) relevant_facts = [edge.fact for edge in edges] ``` **`TypeScript`** ```typescript TypeScript const edges = await client.graph.edge.list(zepGraphUuid, { body: { filters: { connected_node_uuids: [centerNodeUuid] }, }, }); const relevantFacts: string[] = []; for await (const edge of edges) { relevantFacts.push(edge.fact ?? ""); } ``` **`Go`** ```go Go edges, err := zepClient.Graph.Edge.List( context.TODO(), zepGraphUUID, &graph.EdgeListRequest{ Body: &zep.ArtifactListRequest{ Filters: map[string]any{ "connected_node_uuids": []string{centerNodeUUID}, }, }, }, ) if err != nil { log.Fatalf("Error: %v", err) } var relevantFacts []string edgeIterator := edges.Iterator() for edgeIterator.Next(context.TODO()) { edge := edgeIterator.Current() if edge.Fact != nil { relevantFacts = append(relevantFacts, *edge.Fact) } } if err := edgeIterator.Err(); err != nil { log.Fatalf("Error: %v", err) } ``` If you also need the neighboring nodes themselves — not just the facts — use [`graph.node.list_neighbors`](/reading-data-from-the-graph#neighbors-of-a-node), which returns each node connected to `center_node_uuid` together with the edges to it, in one paginated call. > **Note** > > Fetching every edge in the graph and filtering by `source_node_uuid`/`target_node_uuid` client-side works, but scales poorly. Prefer edge listing with `connected_node_uuids` for any graph beyond toy size. You can also retrieve facts relevant to your node by using [edge search](/searching-the-graph) with the node distance re-ranker: **`Python`** ```python Python results = zep_client.graph.search_edges( zep_graph_uuid, query="some query", reranker="node_distance", center_node_uuid=center_node_uuid, ) relevant_edges = results.items or [] relevant_facts = [edge.fact for edge in relevant_edges] ``` **`TypeScript`** ```typescript TypeScript const searchResults = await client.graph.searchEdges(zepGraphUuid, { body: { query: "some query", reranker: "node_distance", centerNodeUuid: centerNodeUuid, }, }); const relevantEdges = searchResults.data; const relevantFactsByDistance = relevantEdges.map(edge => edge.fact); ``` **`Go`** ```go Go searchResults, err := zepClient.Graph.SearchEdges( context.TODO(), zepGraphUUID, &zep.GraphSearchEdgesRequest{ Body: &zep.SearchRequest{ Query: "some query", Reranker: zep.SearchRequestRerankerNodeDistance.Ptr(), CenterNodeUUID: zep.String(centerNodeUUID), }, }, ) if err != nil { log.Fatalf("Error: %v", err) } var relevantFactsByDistance []string for _, edge := range searchResults.Results { if edge.Fact != nil { relevantFactsByDistance = append(relevantFactsByDistance, *edge.Fact) } } ``` ## Summary In this recipe, we went through how to retrieve facts which are related to a specific node in a Zep knowledge graph. We first went through some methods for determining the UUID of the node you are interested in. Then, we went through some methods for retrieving the facts related to that node. > Retrieve facts connected to an entity in a Context Graph