TypeScript SDK Quickstart
Get started with the Endee TypeScript SDK to build powerful vector search applications. This guide will walk you through installation, setup, and creating your first index.
Requirements
- Node.js 18.0.0 or higher
- Endee Local server running (see Quick Start)
New to Endee? Set up your local environment first by following the Quick Start Guide.
Installation
Install the Endee TypeScript SDK using npm:
npm install endeeOr using yarn:
yarn add endeeSetup Endee and Create Index
Initialize the Client
The Endee client is the main interface for all vector operations. Initialize it to connect to your local server:
import { Endee } from 'endee';
// Connect to local Endee server (defaults to localhost:8080)
const client = new Endee();Using Authentication? If your server has NDD_AUTH_TOKEN set, pass the same token when initializing:
const client = new Endee('your-auth-token');See Authentication for details.
Create a Dense Index
Create a vector index for semantic similarity search:
import { Endee, Precision } from 'endee';
const client = new Endee();
await client.createIndex({
name: 'my_vectors',
dimension: 384,
spaceType: 'cosine',
precision: Precision.INT8D,
});Dense Index Parameters: (see CreateIndexOptions)
| Parameter | Description |
|---|---|
name | Unique name for your index |
dimension | Vector dimensionality (must match your embedding model’s output) |
spaceType | Distance metric - "cosine", "l2", or "ip" (see SpaceType) |
M | Graph connectivity - higher values increase recall but use more memory (default: 16) |
efCon | Construction-time parameter - higher values improve index quality (default: 128) |
precision | Quantization precision (default: Precision.INT8D) - see Precision |
Create a Hybrid Index
Hybrid indexes combine dense vector search with sparse vector search for improved retrieval. Add the sparseDimension parameter to enable hybrid search:
await client.createIndex({
name: 'my_hybrid_index',
dimension: 384, // Dense vector dimension
sparseDimension: 30000, // Sparse vector dimension (vocabulary size)
spaceType: 'cosine',
precision: Precision.INT8D,
});Additional Hybrid Parameter:
| Parameter | Description |
|---|---|
sparseDimension | Sparse vector dimension (e.g., vocabulary size for SPLADE) |
List and Access Indexes
// List all indexes
const indexes = await client.listIndexes();
// Get reference to an existing index
const index = await client.getIndex('my_vectors');
// Delete an index
await client.deleteIndex('my_vectors');Complete Example
Here’s a complete example putting it all together:
import { Endee, Precision } from 'endee';
// Initialize client
const client = new Endee();
// Create a dense index
await client.createIndex({
name: 'documents',
dimension: 384,
spaceType: 'cosine',
precision: Precision.INT8D,
});
// Get the index
const index = await client.getIndex('documents');
// Add vectors
await index.upsert([
{
id: 'doc1',
vector: [0.1, 0.2, ...], // 384-dimensional vector
meta: { title: 'First Document' },
filter: { category: 'tech' },
},
{
id: 'doc2',
vector: [0.3, 0.4, ...],
meta: { title: 'Second Document' },
filter: { category: 'science' },
},
]);
// Query the index
const results = await index.query({
vector: [0.15, 0.25, ...],
topK: 5,
});
for (const item of results) {
console.log(`ID: ${item.id}, Similarity: ${item.similarity}`);
}Next Steps
Now that you have your index set up, learn how to: