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 '{
"source_node_id": "node_meeting",
"target_node_id": "node_project",
"relationship_type": "references",
"weight": 0.9,
"metadata": {"context": "Mentioned in section 2"}
}'

Request Body:

FieldTypeRequiredDescription
source_node_idstringYesStarting node
target_node_idstringYesEnding node
relationship_typestringYesType of connection
weightfloatNoStrength (0-1)
metadataobjectNoCustom 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:

ParameterTypeDescription
node_idstringGet relationships for a node
relationship_typestringFilter by type
pageintegerPage number
per_pageintegerItems 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

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