Skip to main content
The Entities API provides an interface for managing entities (people, companies, products, places, etc.) within your project.

Overview

const client = new NdxClient({
  apiKey: process.env.NEURADEX_API_KEY,
  projectId: 'your-project-id',
});

// Access Entities API
const entities = await client.entities.list();
const entity = await client.entities.create({
  canonicalName: 'John Smith',
  type: 'person',
});

Method List

MethodDescription
list(options?)Get entity list
get(entityId)Get specific entity
create(input)Create entity
update(entityId, input)Update entity
delete(entityId)Delete entity
getAliases(entityId)Get aliases
addAlias(entityId, alias)Add alias
removeAlias(entityId, aliasId)Remove alias
getRelations(entityId)Get relations
addRelation(entityId, targetId, type)Add relation
removeRelation(entityId, relationId)Remove relation
getKnowledges(entityId)Get related Knowledge
getTopics(entityId)Get related Topics
getEpisodes(entityId)Get related Episodes
findSimilar(options?)Find similar entities
merge(input)Merge entities
getGraph()Get relation graph

Entity Types

TypeDescription
personPeople
companyCompanies/Organizations
productProducts/Services
placePlaces
otherOthers

list()

Get a list of entities.

Parameters

options.type
string
Filter by entity type: 'person' | 'company' | 'product' | 'place' | 'other'
Search keyword
options.page
number
default:"1"
Page number
options.limit
number
default:"50"
Items per page

Example

// Get all entities
const result = await client.entities.list();
console.log(`Entity count: ${result.total}`);

// People only
const people = await client.entities.list({ type: 'person' });

// Search
const results = await client.entities.list({ search: 'John' });

get()

Get a specific entity (including aliases).

Parameters

entityId
string
required
Entity ID

Example

const entity = await client.entities.get('entity-id');

console.log(`Name: ${entity.canonicalName}`);
console.log(`Type: ${entity.type}`);
console.log(`Aliases: ${entity.aliases.map(a => a.alias).join(', ')}`);

create()

Create a new entity.

Parameters

canonicalName
string
required
Canonical name
type
string
required
Entity type: 'person' | 'company' | 'product' | 'place' | 'other'
aliases
string[]
Array of aliases

Example

const entity = await client.entities.create({
  canonicalName: 'John Smith',
  type: 'person',
  aliases: ['John', 'J. Smith'],
});

console.log(`Created: ${entity.id}`);

update()

Update an entity.

Parameters

entityId
string
required
Entity ID
canonicalName
string
New canonical name
type
string
New type

Example

const updated = await client.entities.update('entity-id', {
  canonicalName: 'John Smith (Manager)',
});

delete()

Delete an entity.

Example

await client.entities.delete('entity-id');

addAlias()

Add an alias to an entity.

Parameters

entityId
string
required
Entity ID
alias
string
required
Alias string
createdBy
string
default:"user"
Created by: 'user' | 'llm' | 'import'

Example

const alias = await client.entities.addAlias('entity-id', 'Johnny');

removeAlias()

Remove an alias.

Example

await client.entities.removeAlias('entity-id', 'alias-id');

getRelations()

Get entity relations (outgoing and incoming).

Example

const relations = await client.entities.getRelations('entity-id');

// Outgoing (from this entity to others)
for (const rel of relations.outgoing) {
  console.log(`${rel.relationType}${rel.targetEntity.canonicalName}`);
}

// Incoming (from others to this entity)
for (const rel of relations.incoming) {
  console.log(`${rel.sourceEntity.canonicalName}${rel.relationType}`);
}

addRelation()

Add a relation between entities.

Parameters

entityId
string
required
Source entity ID
targetEntityId
string
required
Target entity ID
relationType
string
required
Relation type

Relation Types

TypeDescription
works_forWorks for ~
employsEmploys ~
member_ofMember of ~
ownsOwns ~
partner_ofPartner of ~
competitor_ofCompetitor of ~
subsidiary_ofSubsidiary of ~
parent_company_ofParent company of ~
located_inLocated in ~
related_toRelated to ~

Example

const relation = await client.entities.addRelation(
  'person-entity-id',
  'company-entity-id',
  'works_for'
);

getKnowledges()

Get Knowledge related to an entity.

Example

const result = await client.entities.getKnowledges('entity-id');

for (const k of result.knowledges) {
  console.log(`${k.knowledgeTitle}: "${k.mentionText}"`);
}

getTopics()

Get Topics related to an entity.

Example

const result = await client.entities.getTopics('entity-id');

for (const t of result.topics) {
  console.log(`${t.topicTitle}: "${t.mentionText}"`);
}

getEpisodes()

Get Episodes related to an entity.

Example

const result = await client.entities.getEpisodes('entity-id');

for (const e of result.episodes) {
  console.log(`"${e.mentionText}" in episode`);
}

findSimilar()

Find similar entities (duplicate detection).

Parameters

options.threshold
number
Similarity threshold
options.limit
number
Max results

Example

const pairs = await client.entities.findSimilar();

for (const pair of pairs) {
  console.log(`Similar: ${pair.entity1.canonicalName}${pair.entity2.canonicalName}`);
  console.log(`Score: ${pair.similarity}`);
}

merge()

Merge two entities into one.

Parameters

keepEntityId
string
required
Entity ID to keep
mergeEntityId
string
required
Entity ID to merge (will be deleted)

Example

const result = await client.entities.merge({
  keepEntityId: 'entity-1',
  mergeEntityId: 'entity-2',
});

console.log(`Merge complete:`);
console.log(`- Aliases: ${result.mergedAliases}`);
console.log(`- Knowledge: ${result.migratedKnowledges}`);
console.log(`- Episodes: ${result.migratedEpisodes}`);

getGraph()

Get entity relation graph.

Example

const graph = await client.entities.getGraph();

console.log(`Nodes: ${graph.nodes.length}`);
console.log(`Edges: ${graph.edges.length}`);

// Nodes
for (const node of graph.nodes) {
  console.log(`${node.canonicalName} (${node.type})`);
}

// Edges
for (const edge of graph.edges) {
  console.log(`${edge.source} --${edge.relationType}--> ${edge.target}`);
}

Next Steps

What is Entity

Understand the Entity concept

Knowledge API

Knowledge management