UnSearch Docs

Knowledge Graph API

Entity extraction, relationship mapping, and knowledge graph search (Glean-like).

Knowledge Graph API

Extract entities and relationships from text, build knowledge graphs, and search across them. Inspired by Glean's enterprise knowledge graph.

Extract Entities

POST /api/v1/knowledge/extract

Extract named entities and their relationships from text.

Body Parameters

ParameterTypeDefaultDescription
textstringrequiredText to extract entities from
typesstring[]Entity types to extract (e.g., ["person", "company", "technology"])

Example Request

curl -X POST 'https://api.unsearch.dev/api/v1/knowledge/extract' \
  -H 'X-API-Key: sk_live_xxxxx' \
  -H 'Content-Type: application/json' \
  -d '{
    "text": "Sam Altman, CEO of OpenAI, announced GPT-5 at their San Francisco headquarters. The model was developed in partnership with Microsoft.",
    "types": ["person", "company", "product", "location"]
  }'

Response

{
  "entities": [
    {
      "id": "ent_001",
      "type": "person",
      "name": "Sam Altman",
      "description": "CEO of OpenAI",
      "source_count": 1,
      "metadata": { "role": "CEO" }
    },
    {
      "id": "ent_002",
      "type": "company",
      "name": "OpenAI",
      "description": "AI research company",
      "source_count": 1,
      "metadata": {}
    },
    {
      "id": "ent_003",
      "type": "product",
      "name": "GPT-5",
      "description": "AI language model",
      "source_count": 1,
      "metadata": {}
    },
    {
      "id": "ent_004",
      "type": "company",
      "name": "Microsoft",
      "description": "Technology company",
      "source_count": 1,
      "metadata": {}
    }
  ],
  "relationships": [
    {
      "from_entity": "ent_001",
      "to_entity": "ent_002",
      "type": "leads",
      "weight": 0.95,
      "source": "direct"
    },
    {
      "from_entity": "ent_002",
      "to_entity": "ent_003",
      "type": "developed",
      "weight": 0.9,
      "source": "direct"
    },
    {
      "from_entity": "ent_002",
      "to_entity": "ent_004",
      "type": "partnered_with",
      "weight": 0.85,
      "source": "direct"
    }
  ],
  "processing_time_ms": 450
}

Search Knowledge Graph

POST /api/v1/knowledge/search

Search across extracted entities and relationships.

Body Parameters

ParameterTypeDefaultDescription
querystringrequiredSearch query
entity_typesstring[]Filter by entity type
max_resultsinteger10Max entities to return
include_relationshipsbooleantrueInclude related entities

Example Request

curl -X POST 'https://api.unsearch.dev/api/v1/knowledge/search' \
  -H 'X-API-Key: sk_live_xxxxx' \
  -H 'Content-Type: application/json' \
  -d '{
    "query": "OpenAI partnerships",
    "entity_types": ["company"],
    "include_relationships": true
  }'

Response

{
  "entities": [
    {
      "id": "ent_002",
      "type": "company",
      "name": "OpenAI",
      "description": "AI research company",
      "source_count": 5,
      "metadata": {}
    }
  ],
  "relationships": [
    {
      "from_entity": "ent_002",
      "to_entity": "ent_004",
      "type": "partnered_with",
      "weight": 0.85
    }
  ],
  "query": "OpenAI partnerships"
}

Search People

POST /api/v1/knowledge/people

Search for people with role and organization filtering.

Body Parameters

ParameterTypeDefaultDescription
querystringrequiredSearch query
organizationstringFilter by organization
rolestringFilter by role
max_resultsinteger10Max results

Response

{
  "people": [
    {
      "id": "ent_001",
      "name": "Sam Altman",
      "title": "CEO",
      "organization": "OpenAI",
      "email": null,
      "expertise": ["AI", "startups", "technology"],
      "recent_activity": [],
      "relevance_score": 0.95
    }
  ],
  "query": "AI executives"
}

Get Entity Details

GET /api/v1/knowledge/entities/{entity_id}

Get full details for an entity including all relationships.

{
  "entity": {
    "id": "ent_002",
    "type": "company",
    "name": "OpenAI",
    "description": "AI research company",
    "source_count": 5,
    "metadata": {}
  },
  "relationships": [
    {
      "from_entity": "ent_002",
      "to_entity": "ent_001",
      "type": "employs",
      "weight": 0.95
    }
  ]
}

Get Knowledge Graph

GET /api/v1/knowledge/graph

Get the full knowledge graph as nodes and edges.

Query Parameters

ParameterTypeDefaultDescription
entity_typesstring[]Filter by entity type
limitinteger100Max nodes

Response

{
  "nodes": [
    { "id": "ent_001", "type": "person", "name": "Sam Altman" },
    { "id": "ent_002", "type": "company", "name": "OpenAI" }
  ],
  "edges": [
    { "from": "ent_001", "to": "ent_002", "type": "leads", "weight": 0.95 }
  ]
}

Delete Entity

DELETE /api/v1/knowledge/entities/{entity_id}

{ "deleted": true, "entity_id": "ent_001" }

On this page