Skip to main content
The Knowledge API is an interface for managing structured knowledge.

Overview

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

// Access Knowledge API
client.knowledge.search('query');
client.knowledge.get('id');
client.knowledge.create({ ... });

Method List

MethodDescription
search(query, options?)Semantic search
get(id)Get details (full content + related knowledge)
list()Get all knowledge
create(input)Create knowledge
bulkCreate(items)Bulk create
update(id, input)Update knowledge
delete(id)Delete knowledge
export()Export all knowledge
getHistory(id, options?)Get change history
getEdges(id, options?)Get related edges

Execute semantic search. Returns knowledge related to natural language queries.
Search results do not include full content. Use get() when content is needed.

Parameters

query
string
required
Search query (natural language)
options.limit
number
default:"10"
Maximum number of results

Return Value

interface SearchResult {
  id: string;
  title: string;
  tags: string[];
  score: number;           // Relevance score (0-1)
  summary: string | null;  // LLM-generated summary
  contentTokens: number | null;
  createdAt: string | null;
  indexedAt: string | null;
}

Usage

// Basic search
const results = await client.knowledge.search('authentication mechanism');

for (const result of results) {
  console.log(`${result.title} (score: ${result.score.toFixed(2)})`);
}

// Specify result count
const topResults = await client.knowledge.search('returns', { limit: 5 });

get()

Get knowledge details. Includes full content and related knowledge.

Parameters

id
string
required
Knowledge ID

Return Value

interface KnowledgeViewResponse {
  id: string;
  title: string;
  content: string;
  tags: string[];
  summary: string | null;
  contentTokens: number | null;
  createdAt: string;
  updatedAt: string;
  connectedKnowledge: ConnectedKnowledge[];
}

interface ConnectedKnowledge {
  id: string;
  title: string;
  relationType: string;
  weight: number;
  isActive: boolean;
  validFrom: string;
  validUntil: string | null;
}

Usage

const detail = await client.knowledge.get('knowledge-id');

console.log(detail.title);
console.log(detail.content);

// Check related knowledge
for (const connected of detail.connectedKnowledge) {
  console.log(`Related: ${connected.title} (${connected.relationType})`);
}

list()

Get all knowledge in the project.

Return Value

interface Knowledge {
  id: string;
  title: string;
  content: string;
  tags: string[];
  createdAt: string;
  updatedAt: string;
}

Usage

const allKnowledge = await client.knowledge.list();

console.log(`Knowledge count: ${allKnowledge.length}`);

create()

Create new knowledge.

Parameters

title
string
required
Knowledge title
content
string
required
Knowledge content
tags
string[]
Array of tags

Usage

const knowledge = await client.knowledge.create({
  title: 'Introduction to React Hooks',
  content: `
    React Hooks allow function components to use state and lifecycle features.

    ## useState
    Manages component state.

    ## useEffect
    Handles side effects (API calls, DOM operations, etc.).
  `,
  tags: ['React', 'Frontend', 'JavaScript'],
});

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

bulkCreate()

Create multiple knowledge entries at once.

Parameters

items
CreateKnowledgeInput[]
required
Array of knowledge to create

Usage

const items = await client.knowledge.bulkCreate([
  {
    title: 'TypeScript Basics',
    content: 'TypeScript is a statically typed superset of JavaScript.',
    tags: ['TypeScript', 'Programming'],
  },
  {
    title: 'Node.js Basics',
    content: 'Node.js is a server-side JavaScript runtime environment.',
    tags: ['Node.js', 'Backend'],
  },
]);

console.log(`Created ${items.length} items`);

update()

Update existing knowledge.

Parameters

id
string
required
Knowledge ID
title
string
New title
content
string
New content

Usage

// Update title only
const updated = await client.knowledge.update('knowledge-id', {
  title: 'New Title',
});

// Update content only
const updated = await client.knowledge.update('knowledge-id', {
  content: 'Updated content',
});

// Update both
const updated = await client.knowledge.update('knowledge-id', {
  title: 'New Title',
  content: 'Updated content',
});

delete()

Delete knowledge.

Parameters

id
string
required
Knowledge ID

Usage

await client.knowledge.delete('knowledge-id');
console.log('Deleted');

export()

Get all knowledge in export format.

Return Value

Array<{ title: string; content: string }>

Usage

const exported = await client.knowledge.export();

// Save as JSON
import fs from 'fs';
fs.writeFileSync('knowledge-backup.json', JSON.stringify(exported, null, 2));

getHistory()

Get knowledge change history. Returns creation, update, and deletion events chronologically.

Parameters

id
string
required
Knowledge ID
options.limit
number
Maximum number of history entries

Usage

const history = await client.knowledge.getHistory('knowledge-id');

for (const episode of history) {
  console.log(`${episode.episodeType}: ${episode.content}`);
  console.log(`  Reason: ${episode.changeReason}`);
  console.log(`  Actor: ${episode.actorName}`);
  console.log(`  Date: ${episode.occurredAt}`);
}

getEdges()

Get edges (relationships) related to knowledge.

Parameters

id
string
required
Knowledge ID
options.activeOnly
boolean
default:"true"
Get only active edges
options.includeHistory
boolean
default:"false"
Include past edges (deactivated)

Usage

// Active edges only
const activeEdges = await client.knowledge.getEdges('knowledge-id');

// Include history
const allEdges = await client.knowledge.getEdges('knowledge-id', {
  includeHistory: true,
});

for (const edge of allEdges) {
  console.log(`${edge.title} (${edge.relationType})`);
  console.log(`  Active: ${edge.isActive}`);
  console.log(`  Valid: ${edge.validFrom} - ${edge.validUntil ?? 'present'}`);
}

Next Steps

Memory API

Context assembly

Episodes API

Event and history recording