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

@otter-sh/source-clickhouse

v0.1.0

Published

ClickHouse source for [Otter](https://github.com/tomnagengast/otter). Implements the `Source` interface from [`@otter-sh/core`](https://www.npmjs.com/package/@otter-sh/core) over the ClickHouse HTTP interface using `FORMAT JSONEachRow` — **no native Click

Readme

@otter-sh/source-clickhouse

ClickHouse source for Otter. Implements the Source interface from @otter-sh/core over the ClickHouse HTTP interface using FORMAT JSONEachRowno native ClickHouse client dependency. Streams rows via fetch in batches of 5 000.

Install

bun add @otter-sh/source-clickhouse

Add it to your project's dependencies alongside @otter-sh/core and @otter-sh/cli. Requires Bun.

Configuration

Import clickhouseSource and declare the source under sources in otter.config.ts:

import { postgresAdapter } from "@otter-sh/adapter-postgres";
import { defineConfig } from "@otter-sh/core";
import { clickhouseSource } from "@otter-sh/source-clickhouse";

export default defineConfig({
  profiles: { dev: { target: postgresAdapter({ url: process.env.PG_URL ?? "" }) } },
  sources: {
    events_ch: clickhouseSource({
      url: process.env.CLICKHOUSE_URL ?? "http://localhost:8123",
    }),
  },
  modelsDir: "models",
});

| Option | Type | Default | Description | | ------ | -------- | ------- | ------------------------------------ | | url | string | — | HTTP(S) URL of the ClickHouse server |

Auth

Embed credentials in the URL (http://user:[email protected]:8123). The driver strips them from the URL and attaches an Authorization: Basic … header. URL-encoded characters in the user/password are decoded before base64 encoding.

Streams

A stream name passed to otter load <source>.<stream> maps directly to a ClickHouse table. Dotted names like default.events are split and each segment is backtick-quoted independently (`default`.`events`).

otter load events_ch.events
otter load events_ch.logs.app_errors   # quoted as `logs`.`app_errors`

Extract behavior

  • DESCRIBE TABLE runs first so the target CREATE TABLE uses real Postgres types. ClickHouse types are mapped: Int64/UInt64bigint, Float64double precision, DateTime*timestamptz, etc.
  • HTTP POST to the ClickHouse endpoint with default_format=JSONEachRow on the query string.
  • Body: SELECT * FROM <quoted-stream>[ WHERE <cursor_field> > <cursor>][ ORDER BY <cursor_field> ASC] FORMAT JSONEachRow.
  • The response body is read as a stream; each newline-delimited JSON line is parsed into a Row and buffered into 5 000-row batches yielded as AsyncIterable<Row[]>.

Incremental loads

Declare a cursor per stream in sources/<name>.ts:

// sources/events_ch.ts
import { defineSource } from "@otter-sh/core";

export default defineSource({
  streams: {
    events: {
      write_disposition: "append",
      incremental: { cursor_field: "event_time" },
    },
  },
});

The driver rewrites the SQL to WHERE <cursor_field> > <cursor> ORDER BY <cursor_field> ASC and writes the max value seen in the response back to .otter/state.db after the stream drains. Pass --full-refresh to otter load to clear the cursor.

The full result set streams in a single HTTP request — no client-side pagination.

Example

otter load events_ch.events --strategy append

Full documentation

License

MIT