npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@selfmemory/sdk

v0.9.5

Published

TypeScript SDK for the SelfMemory API — universal memory layer for AI apps

Readme

selfmemory

TypeScript SDK for the SelfMemory API — universal memory layer for AI apps.

Installation

npm install selfmemory

Quick Start

import { SelfMemory } from 'selfmemory'

const memory = new SelfMemory({
  apiKey: process.env.SELFMEMORY_API_KEY!,
})

// Store a memory
await memory.add('User prefers dark mode and uses TypeScript', {
  tags: 'preferences,tech',
  topic_category: 'settings',
  user_id: 'user_123',
})

// Search memories
const results = await memory.search('what does the user prefer?', {
  user_id: 'user_123',
  limit: 5,
})

console.log(results.results)

Configuration

const memory = new SelfMemory({
  apiKey: 'sk_im_...',             // Required — project-scoped API key
  host: 'https://api.selfmemory.com', // Optional — defaults to managed API
})

| Option | Type | Required | Default | Description | |--------|------|----------|---------|-------------| | apiKey | string | Yes | — | Project-scoped API key from the SelfMemory dashboard | | host | string | No | https://api.selfmemory.com | API base URL |

API Reference

add(content, options?)

Store a memory.

const result = await memory.add('Meeting with Sarah about Q4 roadmap', {
  tags: 'work,meeting',
  people_mentioned: 'Sarah',
  topic_category: 'business',
  user_id: 'user_123',
})
// { success: true, memory_id: '...', message: '...' }

| Option | Type | Description | |--------|------|-------------| | tags | string | Comma-separated tags | | people_mentioned | string | Comma-separated names | | topic_category | string | Topic classification | | metadata | Record<string, unknown> | Additional metadata | | user_id | string | Scope to a specific end-user |

search(query, options?)

Semantic search across memories.

const results = await memory.search('project discussions', {
  limit: 10,
  tags: ['work', 'meeting'],
  temporal_filter: 'this_week',
  threshold: 0.7,
  user_id: 'user_123',
})

| Option | Type | Description | |--------|------|-------------| | limit | number | Max results (default: 10) | | tags | string[] | Filter by tags | | people_mentioned | string[] | Filter by people | | topic_category | string | Filter by topic | | temporal_filter | string | Time filter (today, this_week, this_month) | | threshold | number | Min similarity score (0-1) | | match_all_tags | boolean | Require all tags to match | | user_id | string | Scope to a specific end-user |

getAll(options?)

List all memories with pagination.

const all = await memory.getAll({ limit: 50, offset: 0 })

get(memoryId)

Get a single memory by ID.

const mem = await memory.get('memory-uuid-here')

update(memoryId, data)

Update a memory.

await memory.update('memory-uuid', {
  text: 'Updated content',
  metadata: { tags: 'updated' },
})

delete(memoryId)

Delete a single memory.

await memory.delete('memory-uuid')

deleteAll(options?)

Delete all memories.

await memory.deleteAll({ user_id: 'user_123' })

searchByTags(tags, options?)

Search by tags with optional semantic query.

const results = await memory.searchByTags(['work', 'important'], {
  semantic_query: 'deadlines',
  match_all: true,
  limit: 10,
})

searchByPeople(people, options?)

Search by people mentioned.

const results = await memory.searchByPeople(['Sarah', 'Mike'], {
  semantic_query: 'project updates',
})

temporalSearch(temporalQuery, options?)

Search by time range.

const results = await memory.temporalSearch('yesterday', {
  semantic_query: 'meetings',
})

getStats(projectId?)

Get memory statistics.

const stats = await memory.getStats()
// { total: 150, this_week: 12, tag_count: 25 }

health()

Health check.

const status = await memory.health()

Error Handling

import { SelfMemory, SelfMemoryError } from 'selfmemory'

try {
  await memory.get('nonexistent-id')
} catch (err) {
  if (err instanceof SelfMemoryError) {
    console.error(err.status)  // 404
    console.error(err.detail)  // "Memory not found"
  }
}

TypeScript

All types are exported:

import type { Memory, SearchOptions, AddResponse } from 'selfmemory'

Requirements

  • Node.js 18+ (uses native fetch)
  • Works in modern browsers

License

MIT