Skip to content
SolidRusT.ai

Knowledge Graph

Queries the knowledge graph for entities and their relationships. Supports configurable traversal depth, direction, and relationship type filtering.

POST https://api.solidrust.ai/data/v1/query/knowledge-graph
ParameterTypeRequiredDefaultDescription
entitystring✅ YesEntity name to query relationships for
relationship_typesstring[]NoallFilter by relationship types
directionstringNobothTraversal direction: outgoing, incoming, both
depthintegerNo2Graph traversal depth (1–5)
limitintegerNo50Maximum results
Terminal window
curl -X POST "https://api.solidrust.ai/data/v1/query/knowledge-graph" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"entity": "Python",
"relationship_types": ["uses", "implements", "related_to"],
"direction": "both",
"depth": 2,
"limit": 50
}'
import requests
API_KEY = "YOUR_API_KEY"
BASE_URL = "https://api.solidrust.ai"
def knowledge_graph_query(
entity: str,
relationship_types: list[str] | None = None,
direction: str = "both",
depth: int = 2,
limit: int = 50,
) -> dict:
"""Query entity relationships in the knowledge graph."""
payload = {
"entity": entity,
"direction": direction,
"depth": depth,
"limit": limit,
}
if relationship_types:
payload["relationship_types"] = relationship_types
response = requests.post(
f"{BASE_URL}/data/v1/query/knowledge-graph",
headers={
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
},
json=payload,
)
return response.json()
result = knowledge_graph_query(
entity="Authentication",
direction="both",
depth=2,
)
print(f"Found {len(result['entities'])} entities and {len(result['relationships'])} relationships")
for entity in result["entities"]:
print(f" {entity['name']} ({entity['entity_type']})")
for rel in result["relationships"]:
print(f" {rel['source']} —[{rel['relationship_type']}]→ {rel['target']}")
async function knowledgeGraphQuery(entity, options = {}) {
const payload = {
entity,
direction: options.direction || 'both',
depth: options.depth || 2,
limit: options.limit || 50,
};
if (options.relationshipTypes) payload.relationship_types = options.relationshipTypes;
const res = await fetch(`${BASE_URL}/data/v1/query/knowledge-graph`, {
method: 'POST',
headers: { Authorization: `Bearer ${API_KEY}`, 'Content-Type': 'application/json' },
body: JSON.stringify(payload),
});
return res.json();
}
{
"entity": "Python",
"entities": [
{
"id": "node-123",
"name": "FastAPI",
"entity_type": "framework",
"properties": { "description": "Web framework for building APIs" }
}
],
"relationships": [
{
"source": "Python",
"target": "FastAPI",
"relationship_type": "has_framework",
"properties": {}
}
],
"latency_ms": 23.4
}
StatusCodeDescription
400invalid_requestMissing or invalid parameters
401INVALID_API_KEYMissing or invalid API key
503service_unavailableKnowledge graph not enabled