Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

ClickHouse 16 min read How-to mediumAdept

ClickHouse as a streaming HTTP API

ClickHouse 26.8 can serve a parameterized HTTP API directly, removing the thin API layer often placed in front of it. The walkthrough uses the UK property prices dataset to build endpoints with `CREATE HANDLER`. Handlers support typed query-string parameters and regex-captured path parameters, and a restricted API user supplies a JSONEachRow default format and a per-user row `limit`. Handler queries are checked only for syntax at creation, so missing tables or columns surface at call time. An application layer is still needed for business logic, orchestration or custom validation.

Related posts

  • Building single page applications with ClickHouse

    ClickHouse mediumAdept

    ClickHouse can serve as a direct browser-queried backend for single page applications, removing the API server layer for demos, prototypes and analytics UIs. Doing this safely depends on HTTPS-only access, CORS configuration, parameterized queries to prevent SQL injection, read-only users with role-based access control, query complexity limits and quotas to stop rogue clients from overwhelming the database. Practical guidance covers choosing JSON output formats (streamable EachRow variants for large results, Arrow for high-volume rendering), reading progress and summary headers, the `wait_end_of_query` tradeoff, handling mid-stream errors returned with HTTP 200, and preferring the official @clickhouse/client-web library. ClickHouse Cloud Query Endpoints are suggested for teams wanting an API layer instead.

  • What's New in pg_clickhouse - JSONB Support, SQL value functions, Streaming, and more

    ClickHouse mediumAdept

    pg_clickhouse, the Postgres foreign data wrapper for querying ClickHouse, now pushes down far more operations to ClickHouse. JSONB accessors (->, ->>, jsonb_extract_path) are translated to ClickHouse sub-column syntax. CURRENT_DATE, CURRENT_TIMESTAMP and clock_timestamp() are translated to ClickHouse now()/now64()/nowInBlock64 calls that use the Postgres session time zone and timestamp precision. Array functions now map to their ClickHouse equivalents. Streaming of HTTP driver results in roughly 50MB batches kept container memory under about 100MiB during a full NYC taxi table scan, versus about 600MiB without it.

  • Announcing the new ClickHouse SQL Playground

    ClickHouse mediumAdept

    sql.clickhouse.com is a new public SQL playground offering over 35 datasets (60 TB) and 220 example queries, with syntax highlighting, autocomplete, query parameters, basic charting via Apache ECharts and shareable links. It is a NextJS/React single-page app talking directly to ClickHouse's HTTP interface. Read-only credentials are exposed safely by combining RBAC, query complexity limits (10 billion rows read, 1000 rows returned) and per-IP quotas of 60 queries per hour. The service runs on a fixed 3-node, 30-vCPU ClickHouse Cloud cluster backed by object storage. Live query progress polls system.processes every 100ms by query ID under a separate monitor user, avoiding HTTP progress headers that the browser fetch API can't read.

  • Adding Analytics to an Application in under 10 minutes with ClickHouse Cloud Query Endpoints

    ClickHouse mediumAdept

    ClickHouse Cloud's beta API endpoints turn a saved parameterized SQL query into a secure HTTP POST endpoint, moving SQL out of application code so queries can change without redeploying. The walkthrough adds GitHub stars, issues, forks and PR counts to the ClickPy PyPI dashboard. A query resolves each package's GitHub repo ID from PyPI metadata and aggregates the GitHub events table with uniqExactIf. The endpoint is bound to a read-only role with IP-keyed quotas and optional CORS, then called from a Next.js/React component via a generic fetch helper, returning any of ClickHouse's output formats such as JSONEachRow.

  • ClickHouse Plugin for Grafana - 2.0 Release

    ClickHouse mediumAdept

    Version 2.0 of the ClickHouse Grafana plugin drops its client-side SQL AST parser and implements ad-hoc filters with ClickHouse's new `additional_table_filters` setting (22.7+), so the server injects each filter into the correct clauses, including subqueries. The release also adds HTTP transport via clickhouse-go's native-format-over-HTTP support, which lets traffic go through load balancers and proxies such as ch-proxy, and splits the connection and query timeouts. It adds JSON Object type support, with leaf nodes usable as columns and logs shown in the Explore view and Logs Panel. Breaking changes: the old automatic 'All' variable optimization is replaced by a manual `$__conditionalAll` macro, ad-hoc filters require ClickHouse 22.7+, and read-only users need readonly=2.

The quest for software engineering knowledge.

Look:
Layout: