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

FieldTypeRequiredDescription
namestringYesEntity name
typestringYesEntity type (person, organization, location, etc.)
user_idstringNoScope 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

ParameterTypeDescription
limitintMaximum 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

FieldTypeRequiredDescription
subjectstringYesSource entity name
subject_typestringYesSource entity type
predicatestringYesRelationship type (e.g. works_at, knows)
objectstringYesTarget entity name
object_typestringYesTarget entity type
memory_idstringNoLink 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

ParameterTypeDescription
limitintMaximum results (default: 100)

Delete Relationship

DELETE /v1/graph/relationships

Query Parameters

All three are required:

ParameterTypeDescription
subjectstringSource entity name
predicatestringRelationship type
objectstringTarget entity name

Query Graph

Traverse the graph from an entity using BFS.

POST /v1/graph/query

Request Body

FieldTypeRequiredDefaultDescription
entitystringYes-Starting entity name
depthintNo2Traversal 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

FieldTypeDescription
querystringSearch term
limitintMaximum results (default: 20)

Extract Knowledge

Extract entities and relationships from text using LLM.

POST /v1/graph/extract

Request Body

FieldTypeRequiredDescription
textstringYesText to extract from
memory_idstringNoLink entities to a memory
user_idstringNoScope 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"}
  ]
}