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

quickwit-js

v0.3.6

Published

Lightweight TypeScript client for Quickwit search engine

Readme

quickwit-js

A lightweight, universal TypeScript client for Quickwit search engine.

Installation

bun add quickwit-js

Quick Start

import { QuickwitClient, AggregationBuilder } from "quickwit-js";

const client = new QuickwitClient("http://localhost:7280");
const logs = client.index("logs");

// Simple search
const results = await logs.search("level:error");
console.log(results.hits);

// With query builder
const results = await logs.search(
  logs.query("error")
    .timeRange(1704067200, 1704153600)
    .limit(20)
    .sortBy("-timestamp")
);

Configuration

const client = new QuickwitClient({
  endpoint: "http://localhost:7280",
  apiKey: "your-api-key",        // optional
  bearerToken: "your-token",     // optional
  timeout: 30000,                // optional, ms
});

Search API

Basic Search

// String query
await logs.search("level:error AND service:api");

// With parameters
await logs.search({
  query: "error",
  max_hits: 50,
  sort_by: ["-timestamp"],
});

Query Builder

const query = logs.query("error")
  .limit(20)
  .offset(0)
  .timeRange(startTs, endTs)      // Unix timestamps (seconds)
  .dateRange(startDate, endDate)  // Date objects
  .sortBy("-timestamp")           // - prefix for descending
  .searchFields("message", "body")
  .snippetFields("message")
  .countAll();

const results = await logs.search(query);

Aggregations

import { AggregationBuilder } from "quickwit-js";

const results = await logs.search(
  logs.query("*")
    .agg("by_level", AggregationBuilder.terms("level", { size: 10 }))
    .agg("over_time", AggregationBuilder.dateHistogram("timestamp", "1h"))
    .agg("response_stats", AggregationBuilder.stats("response_time"))
);

console.log(results.aggregations);

Available aggregations:

  • terms(field, { size?, minDocCount?, order? })
  • histogram(field, interval, { minBound?, maxBound? })
  • dateHistogram(field, interval, { timeZone?, format? })
  • range(field, ranges[])
  • avg(field), sum(field), min(field), max(field)
  • stats(field), percentiles(field, { percents? })
  • count(field)

Convenience Methods

// Get only document sources
const docs = await logs.searchHits("error");

// Get first match
const doc = await logs.searchFirst("error");

// Count matches
const count = await logs.count("level:error");

Error Handling

import {
  QuickwitError,
  ConnectionError,
  TimeoutError,
  NotFoundError
} from "quickwit-js";

try {
  await logs.search("error");
} catch (error) {
  if (error instanceof TimeoutError) {
    console.log(`Timed out after ${error.timeout}ms`);
  } else if (error instanceof NotFoundError) {
    console.log("Index not found");
  } else if (error instanceof ConnectionError) {
    console.log("Failed to connect");
  }
}

Document Ingest

const logs = client.index("logs");

// Ingest documents (batch)
const result = await logs.ingest([
  { timestamp: Date.now(), level: "info", message: "User logged in" },
  { timestamp: Date.now(), level: "error", message: "Connection failed" },
]);
console.log(`Queued ${result.num_docs_for_processing} documents`);

// With commit mode
await logs.ingest(documents, { commit: "auto" });      // Default: queued immediately
await logs.ingest(documents, { commit: "wait_for" });  // Wait for commit threshold
await logs.ingest(documents, { commit: "force" });     // Immediate commit (slower)

Index Management

// Create an index
await client.createIndex({
  version: "0.7",
  index_id: "logs",
  doc_mapping: {
    field_mappings: [
      { name: "timestamp", type: "datetime", fast: true },
      { name: "level", type: "text", tokenizer: "raw" },
      { name: "message", type: "text" },
    ],
    timestamp_field: "timestamp",
  },
});

// Delete an index
await client.deleteIndex("old-logs");

// Clear all documents (keeps index config)
await client.clearIndex("logs");

Client Methods

// Health check
const health = await client.health();
const isHealthy = await client.isHealthy();

// Index operations
const indexes = await client.listIndexes();
const metadata = await client.getIndex("logs");
const exists = await client.indexExists("logs");

Development

bun install
bun test

License

MIT