메인 콘텐츠로 건너뛰기
Entities API는 프로젝트 내의 엔티티(인물, 기업, 제품, 장소 등)를 관리하기 위한 인터페이스입니다.

개요

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

// Entities API에 접근
const entities = await client.entities.list();
const entity = await client.entities.create({
  canonicalName: '김철수',
  type: 'person',
});

메서드 목록

메서드설명
list(options?)엔티티 목록 조회
get(entityId)특정 엔티티 조회
create(input)엔티티 생성
update(entityId, input)엔티티 업데이트
delete(entityId)엔티티 삭제
getAliases(entityId)별칭 목록 조회
addAlias(entityId, alias)별칭 추가
removeAlias(entityId, aliasId)별칭 삭제
getRelations(entityId)관계 조회
addRelation(entityId, targetId, type)관계 추가
removeRelation(entityId, relationId)관계 삭제
getKnowledges(entityId)관련 Knowledge 조회
getTopics(entityId)관련 Topic 조회
getEpisodes(entityId)관련 Episode 조회
findSimilar(options?)유사 엔티티 검출
merge(input)엔티티 병합
getGraph()관계 그래프 조회

엔티티 타입

타입설명
person인물
company기업·조직
product제품·서비스
place장소
other기타

list()

엔티티 목록을 조회합니다.

파라미터

options.type
string
엔티티 타입으로 필터: 'person' | 'company' | 'product' | 'place' | 'other'
검색 키워드
options.page
number
기본값:"1"
페이지 번호
options.limit
number
기본값:"50"
조회 건수

사용 예시

// 전체 엔티티 조회
const result = await client.entities.list();
console.log(`엔티티 수: ${result.total}`);

// 인물만
const people = await client.entities.list({ type: 'person' });

// 검색
const results = await client.entities.list({ search: '김' });

get()

특정 엔티티를 조회합니다(별칭 포함).

파라미터

entityId
string
필수
엔티티 ID

사용 예시

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

console.log(`이름: ${entity.canonicalName}`);
console.log(`타입: ${entity.type}`);
console.log(`별칭: ${entity.aliases.map(a => a.alias).join(', ')}`);

create()

새 엔티티를 생성합니다.

파라미터

canonicalName
string
필수
정식 명칭
type
string
필수
엔티티 타입: 'person' | 'company' | 'product' | 'place' | 'other'
aliases
string[]
별칭 배열

사용 예시

const entity = await client.entities.create({
  canonicalName: '김철수',
  type: 'person',
  aliases: ['김 부장', 'Cheolsu Kim'],
});

console.log(`생성됨: ${entity.id}`);

update()

엔티티를 업데이트합니다.

파라미터

entityId
string
필수
엔티티 ID
canonicalName
string
새 정식 명칭
type
string
새 타입

사용 예시

const updated = await client.entities.update('entity-id', {
  canonicalName: '김철수 (부장)',
});

delete()

엔티티를 삭제합니다.

사용 예시

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

addAlias()

엔티티에 별칭을 추가합니다.

파라미터

entityId
string
필수
엔티티 ID
alias
string
필수
별칭 문자열
createdBy
string
기본값:"user"
생성자: 'user' | 'llm' | 'import'

사용 예시

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

removeAlias()

별칭을 삭제합니다.

사용 예시

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

getRelations()

엔티티의 관계(발신·수신)를 조회합니다.

사용 예시

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

// 발신 (이 엔티티에서 다른 엔티티로)
for (const rel of relations.outgoing) {
  console.log(`${rel.relationType}${rel.targetEntity.canonicalName}`);
}

// 수신 (다른 엔티티에서 이 엔티티로)
for (const rel of relations.incoming) {
  console.log(`${rel.sourceEntity.canonicalName}${rel.relationType}`);
}

addRelation()

엔티티 간 관계를 추가합니다.

파라미터

entityId
string
필수
소스 엔티티 ID
targetEntityId
string
필수
타겟 엔티티 ID
relationType
string
필수
관계 타입

관계 타입

타입설명
works_for~에서 근무
employs~를 고용
member_of~의 멤버
owns~를 소유
partner_of~의 파트너
competitor_of~의 경쟁사
subsidiary_of~의 자회사
parent_company_of~의 모회사
located_in~에 소재
related_to~와 관련

사용 예시

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

getKnowledges()

엔티티와 관련된 Knowledge를 조회합니다.

사용 예시

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

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

getTopics()

엔티티와 관련된 Topic을 조회합니다.

사용 예시

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

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

getEpisodes()

엔티티와 관련된 Episode를 조회합니다.

사용 예시

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

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

findSimilar()

유사한 엔티티를 검출합니다(중복 검출).

파라미터

options.threshold
number
유사도 임계값
options.limit
number
최대 조회 건수

사용 예시

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

for (const pair of pairs) {
  console.log(`유사: ${pair.entity1.canonicalName}${pair.entity2.canonicalName}`);
  console.log(`스코어: ${pair.similarity}`);
}

merge()

두 엔티티를 병합(통합)합니다.

파라미터

keepEntityId
string
필수
유지할 엔티티 ID
mergeEntityId
string
필수
통합될 엔티티 ID(삭제됨)

사용 예시

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

console.log(`병합 완료:`);
console.log(`- 별칭: ${result.mergedAliases}건`);
console.log(`- Knowledge: ${result.migratedKnowledges}건`);
console.log(`- Episode: ${result.migratedEpisodes}건`);

getGraph()

엔티티 관계 그래프를 조회합니다.

사용 예시

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

console.log(`노드 수: ${graph.nodes.length}`);
console.log(`엣지 수: ${graph.edges.length}`);

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

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

다음 단계

Entity란

Entity 개념 이해하기

Knowledge API

지식 관리