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

# Get Knowledge Graph

> Get the knowledge graph visualization data for a Neo4j-based RAG system (nodes, edges, and metadata).



## OpenAPI

````yaml get /v4/knowledge_graph/neo4j/graph/
openapi: 3.0.3
info:
  title: Lyzr Knowledge Graph Visualization API
  version: 1.0.0
  description: API endpoint to retrieve data for visualizing a Neo4j-based knowledge graph.
servers:
  - url: https://rag-prod.studio.lyzr.ai
security: []
paths:
  /v4/knowledge_graph/neo4j/graph/:
    get:
      summary: Get Knowledge Graph
      description: >-
        Get the knowledge graph visualization data for a Neo4j-based RAG system
        (nodes, edges, and metadata).
      operationId: getKnowledgeGraph
      parameters:
        - name: rag_id
          in: query
          required: true
          description: >-
            The unique identifier (ID) of the RAG system to retrieve the graph
            for.
          schema:
            type: string
            example: 654c602a46c3b6d4e28741b0
        - name: limit
          in: query
          required: false
          description: Maximum number of nodes to return to control the visualization size.
          schema:
            type: integer
            default: 50
            minimum: 1
      responses:
        '200':
          description: Knowledge graph data successfully retrieved.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/KnowledgeGraphResponse'
        '422':
          description: >-
            Validation Error (e.g., incorrect RAG ID format or invalid limit
            value).
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: array
                    items:
                      $ref: '#/components/schemas/ValidationError'
        '500':
          description: Graph Visualization Error.
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: string
                    example: >-
                      Graph Visualization Error: '1223242' is not a valid
                      ObjectId, it must be a 12-byte input or a 24-character hex
                      string
      security:
        - ApiKeyAuth: []
components:
  schemas:
    KnowledgeGraphResponse:
      type: object
      description: The data structure containing nodes and edges for graph visualization.
      properties:
        nodes:
          type: array
          items:
            $ref: '#/components/schemas/Node'
        edges:
          type: array
          items:
            $ref: '#/components/schemas/Edge'
        metadata:
          type: object
          description: Additional metadata about the graph (e.g., total count, query time).
          additionalProperties: true
    ValidationError:
      type: object
      properties:
        loc:
          type: array
          items:
            oneOf:
              - type: string
              - type: integer
        msg:
          type: string
        type:
          type: string
    Node:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier for the node.
        label:
          type: string
          description: The type/label of the node (e.g., Person, Product).
        properties:
          type: object
          description: Key-value properties associated with the node.
          additionalProperties: true
    Edge:
      type: object
      properties:
        id:
          type: string
          description: Unique identifier for the edge/relationship.
        source:
          type: string
          description: The ID of the source node.
        target:
          type: string
          description: The ID of the target node.
        type:
          type: string
          description: The type of relationship (e.g., KNOWS, WORKS_AT).
        properties:
          type: object
          description: Key-value properties associated with the edge.
          additionalProperties: true
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````