Knowledge Graph API

The Knowledge Graph API allows you to extract entities and relationships from your documents, visualize the knowledge graph, and perform advanced graph operations.

Get Knowledge Graph Stats

Get statistics about the knowledge graph.

GET /api/knowledge-graph/stats

Response

Returns statistics about the knowledge graph, including entity and relationship counts.

Detect Entities

Detect entities and relationships from document chunks.

POST /api/knowledge-graph/detect-entities

Request Body

ParameterTypeDescriptionDefault
document_idsarrayArray of document IDs to process (optional)null
force_rebuildbooleanWhether to force rebuilding the knowledge graphfalse

Response

Returns a status object with information about the entity detection process.

Get Entity Detection Status

Get the current status of entity detection.

GET /api/knowledge-graph/entity-detection-status

Response

Returns the current status of the entity detection process.

Get Entities

Get list of detected entities.

GET /api/knowledge-graph/entities

Query Parameters

ParameterTypeDescriptionDefault
limitintegerMaximum number of entities to return100
entity_typestringFilter by entity typenull
min_mentionsintegerMinimum number of mentions required2

Response

Returns a list of entities matching the filter criteria.

Get Entity Details

Get a specific entity by ID.

GET /api/knowledge-graph/entities/{entity_id}

Path Parameters

ParameterTypeDescription
entity_idstringID of the entity to retrieve

Response

Returns detailed information about the specified entity.

Merge Entities

Merge multiple entities into one entity.

POST /api/knowledge-graph/merge-entities

Request Body

ParameterTypeDescription
source_entitiesarrayArray of entity IDs to merge
target_entitystringID of the entity to merge into

Response

Returns a status object with information about the merge operation.

Get Relationships

Get list of detected relationships.

GET /api/knowledge-graph/relationships

Query Parameters

ParameterTypeDescriptionDefault
limitintegerMaximum number of relationships to return100
relationship_typestringFilter by relationship typenull

Response

Returns a list of relationships matching the filter criteria.

Get Graph Data

Get data for visualization of the knowledge graph.

POST /api/knowledge-graph/graph-data

Request Body

ParameterTypeDescriptionDefault
node_labelstringLabel of the starting nodeRequired
max_depthintegerMaximum depth of the graph traversal3
max_nodesintegerMaximum number of nodes to return1000
embeddingRankintegerRank of embeddings to use128
useGPUbooleanWhether to use GPU for embedding generationfalse

Response

Returns graph data suitable for visualization.

Get Graph Data (GET method)

GET version of the graph data endpoint for visualization of the knowledge graph.

GET /api/knowledge-graph/graph-data

Query Parameters

ParameterTypeDescriptionDefault
node_labelstringLabel of the starting nodeRequired
max_depthintegerMaximum depth of the graph traversal3
max_nodesintegerMaximum number of nodes to return1000
embeddingRankintegerRank of embeddings to use128
useGPUbooleanWhether to use GPU for embedding generationfalse

Response

Returns graph data suitable for visualization.

Get Hypergraph

Get hypergraph data for visualization.

GET /api/knowledge-graph/hypergraph

Query Parameters

ParameterTypeDescriptionDefault
limit_entitiesintegerMaximum number of entities to include100
limit_hyperedgesintegerMaximum number of hyperedges to include20
embedding_rankintegerRank of embeddings to use128

Response

Returns hypergraph data suitable for visualization.

Get Concept Clusters

Get concept clusters for visualization.

GET /api/knowledge-graph/concept-clusters

Query Parameters

ParameterTypeDescriptionDefault
embedding_rankintegerRank of embeddings to use128

Response

Returns concept cluster data suitable for visualization.

Generate Embeddings

Start the process of generating embeddings.

POST /api/knowledge-graph/generate-embeddings

Query Parameters

ParameterTypeDescriptionDefault
embedding_rankintegerRank of embeddings to generate128
use_gpubooleanWhether to use GPU for embedding generationfalse

Response

Returns a status object with information about the embedding generation process.

Get Embedding Status

Get the current status of embedding generation.

GET /api/knowledge-graph/embedding-status

Response

Returns the current status of the embedding generation process.

Connect to Neo4j

Connect to Neo4j database for knowledge graph storage.

POST /api/knowledge-graph/connect-neo4j

Request Body

ParameterTypeDescriptionDefault
uristringURI of the Neo4j database”bolt://localhost:7687”
usernamestringUsername for Neo4j authentication”neo4j”
passwordstringPassword for Neo4j authentication”password”
databasestringName of the Neo4j database (optional)null

Response

Returns a status object with information about the Neo4j connection.