API Reference

@clickhouse/client

Official ClickHouse client for Node.js with streaming inserts, query result formats, and sessions.

Official Documentation ↗
CompatibilityThis documentation covers version v1. Check the official docs for the latest API surface.

Installation

npmnpm install @clickhouse/client

Methods

The ClickHouse client sends SQL over HTTP and can stream both query results and insert payloads.

Key Features

  • HTTP-based queries with result format control
  • Streaming inserts with JSONEachRow
  • Parameterized queries to prevent injection

Usage Notes

Pin a version and check the official docs for the API surface you depend on before upgrading.

Errors

The following points are quoted verbatim from the official documentation. 来源:https://clickhouse.com/docs/integrations/javascript · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:48:55.525Z. Any error type, throw condition or recovery step not stated there is left unspecified; this page does not infer exception classes or return values.

Security notes

Quoted verbatim from the official documentation; this is not a complete threat model. 来源:https://clickhouse.com/docs/integrations/javascript · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:48:55.525Z.

FAQ

Why is my query failing with a format error?
ClickHouse needs an output format for HTTP responses. The client sets one automatically, but a custom query string must include a FORMAT clause.
How do I parameterize safely?
Use the query_params option and reference values as {name:Type}; do not concatenate strings into SQL.
Can I stream large inserts?
Yes. Pass a Readable stream of JSONEachRow lines to values so the client does not buffer the entire batch in memory.