Graph API
Memoid Graph API reference. Create, query, and manage knowledge graph entities and relationships extracted from AI conversations.
Knowledge graph is built into Memoid using PostgreSQL — no external graph database needed.
Add Entity
POST /v1/graph/entities Request Body
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Entity name |
type | string | Yes | Entity type (person, organization, location, etc.) |
user_id | string | No | Scope to user |
Example
curl -X POST https://api.memoid.dev/v1/graph/entities
-H "Authorization: Bearer YOUR_API_KEY"
-H "Content-Type: application/json"
-d '{
"name": "John Smith",
"type": "person"
}' List Entities
GET /v1/graph/entities Query Parameters
| Parameter | Type | Description |
|---|---|---|
limit | int | Maximum results (default: 100) |
Get Entity
Get a specific entity and its relationships.
GET /v1/graph/entities/:name Delete Entity
Remove an entity and its relationships.
DELETE /v1/graph/entities/:name Add Relationship
Create a directed relationship between two entities.
POST /v1/graph/relationships Request Body
| Field | Type | Required | Description |
|---|---|---|---|
subject | string | Yes | Source entity name |
subject_type | string | Yes | Source entity type |
predicate | string | Yes | Relationship type (e.g. works_at, knows) |
object | string | Yes | Target entity name |
object_type | string | Yes | Target entity type |
memory_id | string | No | Link to a memory |
Example
curl -X POST https://api.memoid.dev/v1/graph/relationships
-H "Authorization: Bearer YOUR_API_KEY"
-H "Content-Type: application/json"
-d '{
"subject": "John",
"subject_type": "person",
"predicate": "works_at",
"object": "Acme Corp",
"object_type": "organization"
}' List Relationships
GET /v1/graph/relationships Query Parameters
| Parameter | Type | Description |
|---|---|---|
limit | int | Maximum results (default: 100) |
Delete Relationship
DELETE /v1/graph/relationships Query Parameters
All three are required:
| Parameter | Type | Description |
|---|---|---|
subject | string | Source entity name |
predicate | string | Relationship type |
object | string | Target entity name |
Query Graph
Traverse the graph from an entity using BFS.
POST /v1/graph/query Request Body
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
entity | string | Yes | - | Starting entity name |
depth | int | No | 2 | Traversal depth |
Example
curl -X POST https://api.memoid.dev/v1/graph/query
-H "Authorization: Bearer YOUR_API_KEY"
-H "Content-Type: application/json"
-d '{
"entity": "John",
"depth": 2
}' Response
{
"results": [
{"name": "Acme Corp", "type": "organization"},
{"name": "San Francisco", "type": "location"}
]
} Search Graph
Text search over entity names.
POST /v1/graph/search Request Body
| Field | Type | Description |
|---|---|---|
query | string | Search term |
limit | int | Maximum results (default: 20) |
Extract Knowledge
Extract entities and relationships from text using LLM.
POST /v1/graph/extract Request Body
| Field | Type | Required | Description |
|---|---|---|---|
text | string | Yes | Text to extract from |
memory_id | string | No | Link entities to a memory |
user_id | string | No | Scope to user |
Example
curl -X POST https://api.memoid.dev/v1/graph/extract
-H "Authorization: Bearer YOUR_API_KEY"
-H "Content-Type: application/json"
-d '{
"text": "Sarah is the CEO of TechCorp. She founded it with Mike in 2020."
}' Response
{
"entities": [
{"name": "Sarah", "type": "person"},
{"name": "TechCorp", "type": "organization"},
{"name": "Mike", "type": "person"}
],
"relationships": [
{"subject": "Sarah", "predicate": "ceo_of", "object": "TechCorp"},
{"subject": "Sarah", "predicate": "founded", "object": "TechCorp"},
{"subject": "Mike", "predicate": "co_founded", "object": "TechCorp"}
]
}