Skip to content

EpistemicDB Quickstart

Get EpistemicDB running in 5 minutes.

Prerequisites

  • Node.js 20+
  • Docker (for PostgreSQL with pgvector)

1. Start the database

bash
git clone <repo-url> && cd epistemicdb
docker compose up -d

This starts PostgreSQL with pgvector on port 5432 and the EpistemicDB server on port 5433.

2. Initialize a project

bash
mkdir my-knowledge-base && cd my-knowledge-base
npx edb init my-kb
npm install @epistemicdb/client

This creates:

  • edb.config.ts — project configuration
  • .env — environment variables (EDB_URL, EDB_KEY)
  • queries/example.eql — sample EQL query

3. Generate types

bash
npx edb gen-types

Generates src/edb.types.ts with typed interfaces for KOs, bonds, and query results.

4. Write your first query

Create queries/my-first.eql:

eql
FETCH KO
  WHERE decay_score > 0.35
  AND confidence > 0.60
  AS projection DYNAMIC
  ORDER BY K DESC
  LIMIT 10

5. Run it

bash
# Against the server
eql query queries/my-first.eql

# Or from TypeScript
typescript
import { createClient } from '@epistemicdb/client'

const edb = createClient('http://localhost:5433', process.env.EDB_KEY!)

const result = await edb.query(`
  FETCH KO
    WHERE entity = "pricing"
    AND decay_score > 0.35
    ORDER BY K DESC
`)

console.log(result.data.rows)

6. Use tagged template literals

typescript
const entity = 'pricing'
const threshold = 0.35

const result = await edb.eql`
  FETCH KO
    WHERE entity = ${entity}
    AND decay_score > ${threshold}
    ORDER BY K DESC
`

7. Subscribe to changes

typescript
const sub = await edb.watch('WATCH KO WHERE entity = "pricing" AND decay_score < 0.40')
sub.on('update', (event) => {
  console.log('KO changed:', event.ko.id, event.changed_fields)
})

Next steps

Released under the MIT License.