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:
| Field | Type | Required | Description |
|---|---|---|---|
from_node_id | string | Yes | Starting node |
to_node_id | string | Yes | Ending node |
relationship_type | string | Yes | Type of connection |
strength | float | No | Strength (0-1) |
confidence | float | No | Confidence (0-1) |
context | string | No | Optional context text |
bidirectional | boolean | No | Create reverse edge too |
graph_view | string | No | identity (default) or neutral |
emotion_type | string | No | Emotional context (e.g., positive, negative) |
sentiment_score | float | No | Sentiment 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:
| Parameter | Type | Description |
|---|---|---|
from_node_id | string | Filter by source node |
to_node_id | string | Filter by target node |
relationship_type | string | Filter by type |
view | string | identity (default) or neutral |
access | string | owned, shared, or all (default) |
include_nodes | boolean | Include 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
| Type | Description |
|---|---|
references | One node mentions another |
related_to | General association |
parent_of / child_of | Hierarchical |
depends_on | Dependency |
created_by | Authorship |
knows | Social connection |