Skip to main content

Relationships API

Manage connections between nodes.

Endpoints

POST /relationships

POST Create a relationship.

curl -X POST "https://api.ofself.ai/api/v1/relationships" \
-H "X-API-Key: your-key" \
-H "X-User-ID: user-123" \
-H "Content-Type: application/json" \
-d '{
"from_node_id": "node_meeting",
"to_node_id": "node_project",
"relationship_type": "references",
"strength": 0.9,
"confidence": 0.95,
"context": "Mentioned in section 2",
"bidirectional": false,
"graph_view": "identity"
}'

Request Body:

FieldTypeRequiredDescription
from_node_idstringYesStarting node
to_node_idstringYesEnding node
relationship_typestringYesType of connection
strengthfloatNoStrength (0-1)
confidencefloatNoConfidence (0-1)
contextstringNoOptional context text
bidirectionalbooleanNoCreate reverse edge too
graph_viewstringNoidentity (default) or neutral
emotion_typestringNoEmotional context (e.g., positive, negative)
sentiment_scorefloatNoSentiment score (-1.0 to 1.0)

Response: 201 Created

{
"id": "rel_a1b2c3d4",
"from_node_id": "node_meeting",
"to_node_id": "node_project",
"relationship_type": "references",
"strength": 0.9,
"confidence": 0.95,
"context": "Mentioned in section 2",
"bidirectional": false,
"created_at": "2024-01-15T10:30:00Z"
}

GET /relationships

GET List relationships.

curl -X GET "https://api.ofself.ai/api/v1/relationships?node_id=node_abc" \
-H "X-API-Key: your-key" \
-H "X-User-ID: user-123"

Query Parameters:

ParameterTypeDescription
from_node_idstringFilter by source node
to_node_idstringFilter by target node
relationship_typestringFilter by type
viewstringidentity (default) or neutral
accessstringowned, shared, or all (default)
include_nodesbooleanInclude node summaries (default: false)

GET /relationships/:relationship_id

GET Get a single relationship.


PUT /relationships/:relationship_id

PUT Update a relationship.

curl -X PUT "https://api.ofself.ai/api/v1/relationships/rel_abc" \
-H "X-API-Key: your-key" \
-H "X-User-ID: user-123" \
-H "Content-Type: application/json" \
-d '{
"strength": 1.0,
"relationship_type": "directly_references"
}'

DELETE /relationships/:relationship_id

DELETE Delete a relationship.

curl -X DELETE "https://api.ofself.ai/api/v1/relationships/rel_abc" \
-H "X-API-Key: your-key" \
-H "X-User-ID: user-123"

Common Relationship Types

TypeDescription
referencesOne node mentions another
related_toGeneral association
parent_of / child_ofHierarchical
depends_onDependency
created_byAuthorship
knowsSocial connection