Retrieves the current state of the knowledge graph.
Response
{
nodes: Node[];
edges: Edge[];
metrics: {
betweenness: Record<number, number>;
eigenvector: Record<number, number>;
degree: Record<number, number>;
};
clusters: ClusterResult[];
}Expands the graph based on a provided prompt.
Request Body
{
prompt: string;
}Response: Same as GET /api/graph
Recalculates semantic clusters for the current graph.
Response: Same as GET /api/graph
Attempts to reconnect disconnected nodes.
Response: Same as GET /api/graph
const protocol = window.location.protocol === "https:" ? "wss:" : "ws:";
const wsUrl = `${protocol}//${window.location.host}/ws`;
const socket = new WebSocket(wsUrl);-
Graph Update
{ type: 'graph_update'; data: GraphData; }
-
Cluster Update
{ type: 'cluster_update'; data: ClusterResult[]; }
All API endpoints return standard HTTP status codes:
- 200: Success
- 400: Bad Request
- 401: Unauthorized
- 500: Server Error
Error responses include a message field:
{
"error": "Error description"
}- 100 requests per minute per IP
- WebSocket connections limited to 1 per client
const response = await fetch('/api/graph/expand', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
prompt: 'Expand knowledge about artificial intelligence'
})
});
const updatedGraph = await response.json();socket.onmessage = (event) => {
const update = JSON.parse(event.data);
if (update.type === 'graph_update') {
updateGraphVisualization(update.data);
}
};