The Type-Safe Query Builder for ClickHouse

Build ClickHouse queries once.
Reuse them everywhere.

Generate types from your schema, build queries with full autocomplete, reuse them across APIs, dashboards, and agents.

No YAML · No string-concatenated SQL · No duplicated metrics

npm downloadsTypeScriptClickHouse

Build Path

Grow from one safe query to a reusable analytics API

hypequery does not force you into a big framework on day one. Start with the query builder, reuse the query when it matters, and when you need it, add HTTP routes, docs, and framework integration.

1. Query builder

Start with a typed ClickHouse query

Start with the query builder when you just want a safe, ergonomic way to query ClickHouse from TypeScript.

query-builder.ts

2. Wrap query

Turn it into an executable definition

Add a description, typed input and re-use across your codebase.

query-definition.ts

3. Add serve

Expose the same query over HTTP

Expose as a shared runtime surface for product APIs, dashboards, and multi-tenant apps.

serve-runtime.ts

Why teams move beyond raw SQL

Type-safe, reusable, consistent

Keep ClickHouse queries type-safe, reusable, and consistent across dashboards, APIs, jobs, and internal tools.

The old way

YAML. SQL strings.

  • Query logic scattered across dashboards, scripts, and services.
  • String-concatenated SQL that drifts as schemas evolve.
  • Metrics definitions duplicated and re-implemented per team.
raw-sql.ts

The hypequery way

Everything is code.

  • Type-safe metrics defined once in TypeScript.
  • Reusable definitions power APIs, jobs, dashboards, and agents.
  • Auth, multi-tenancy, and caching stay consistent everywhere.
type-safe-query.ts

Pick a use case

The API shape stays the same.

The thing that changes is where you use it.

Backend & platform

Backend and platform engineers pull the same hypequery definition into cron jobs, queues, and HTTP handlers so every service agrees on revenue math.

example.ts

What you get

When you need more than a query builder

Typed query definitions you can execute locally

Optional HTTP routes and API docs

One contract reused across apps, jobs, and dashboards

Safer schema changes through generated ClickHouse types

Auth, multi-tenancy, and caching when your app needs them

Framework-friendly handlers for Next.js and Node

Ship faster

Build your first type-safe query
in 30 seconds

Get started with the query builder, then add HTTP APIs and team features when you need them. Teams use it to keep product analytics, finance APIs, and AI agents perfectly in sync.