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 '{
"source_node_id": "node_meeting",
"target_node_id": "node_project",
"relationship_type": "references",
"weight": 0.9,
"metadata": {"context": "Mentioned in section 2"}
}'
Request Body:
| Field | Type | Required | Description |
|---|---|---|---|
source_node_id | string | Yes | Starting node |
target_node_id | string | Yes | Ending node |
relationship_type | string | Yes | Type of connection |
weight | float | No | Strength (0-1) |
metadata | object | No | Custom metadata |
Response: 201 Created
{
"id": "rel_a1b2c3d4",
"source_node_id": "node_meeting",
"target_node_id": "node_project",
"relationship_type": "references",
"weight": 0.9,
"metadata": {"context": "Mentioned in section 2"},
"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 |
|---|---|---|
node_id | string | Get relationships for a node |
relationship_type | string | Filter by type |
page | integer | Page number |
per_page | integer | Items per page |
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 '{
"weight": 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 |