惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

GbyAI
GbyAI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
A
About on SuperTechFans
The Last Watchdog
The Last Watchdog
A
Arctic Wolf
S
Schneier on Security
Cisco Talos Blog
Cisco Talos Blog
K
Kaspersky official blog
Spread Privacy
Spread Privacy
The Hacker News
The Hacker News
P
Proofpoint News Feed
Attack and Defense Labs
Attack and Defense Labs
NISL@THU
NISL@THU
AWS News Blog
AWS News Blog
Schneier on Security
Schneier on Security
TaoSecurity Blog
TaoSecurity Blog
H
Hacker News: Front Page
L
LangChain Blog
Y
Y Combinator Blog
T
Tenable Blog
Microsoft Security Blog
Microsoft Security Blog
L
Lohrmann on Cybersecurity
量子位
N
News and Events Feed by Topic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
The GitHub Blog
The GitHub Blog
云风的 BLOG
云风的 BLOG
W
WeLiveSecurity
Martin Fowler
Martin Fowler
Cloudbric
Cloudbric
S
SegmentFault 最新的问题
Project Zero
Project Zero
D
Darknet – Hacking Tools, Hacker News & Cyber Security
博客园 - 叶小钗
V
Vulnerabilities – Threatpost
小众软件
小众软件
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
腾讯CDC
博客园 - 聂微东
F
Full Disclosure
WordPress大学
WordPress大学
PCI Perspectives
PCI Perspectives
P
Privacy International News Feed
M
MIT News - Artificial intelligence
Forbes - Security
Forbes - Security
Blog — PlanetScale
Blog — PlanetScale
T
The Blog of Author Tim Ferriss
Webroot Blog
Webroot Blog
S
Security @ Cisco Blogs
Last Week in AI
Last Week in AI

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Day 24 of 100 Days of ClickHouse: Working with the ClickHouse HTTP API
Kanishga Subramani · 2026-06-19 · via DEV Community

When most people think about interacting with a database, they imagine using a client library, a graphical interface, or a command-line tool. While these are common approaches, ClickHouse also provides a built-in HTTP API that enables you to communicate with the database using standard HTTP requests.

This means that if your application, script, or service can send an HTTP request, it can interact with ClickHouse. Whether you're using Python, JavaScript, Go, Java, cURL, Postman, or even a simple shell script, the HTTP API provides a universal and lightweight way to execute queries, insert data, and manage your database.

In this article, we'll explore how the ClickHouse HTTP API works, how to use it effectively, and why it's such an important feature for modern applications.


What Is the ClickHouse HTTP API?

The ClickHouse HTTP API is a built-in interface that allows applications to communicate with ClickHouse over the HTTP protocol.

Instead of connecting through the native ClickHouse protocol, your application simply sends an HTTP request containing an SQL query, and ClickHouse executes it before returning the result.

By default, the HTTP API runs on port 8123 and supports both GET and POST requests.

Unlike the native protocol, the HTTP interface is:

  • Language independent
  • Easy to integrate with any application
  • Firewall friendly
  • Ideal for automation
  • Simple to test using browsers, cURL, or Postman

This flexibility makes it popular for scripting, automation, lightweight services, and REST-based applications.


How the HTTP API Works

The communication flow is straightforward:

Application
     │
     ▼
HTTP Request
     │
     ▼
ClickHouse Server
     │
     ▼
SQL Execution
     │
     ▼
HTTP Response

The response can be returned in many formats including JSON, CSV, TSV, Parquet, Arrow, and more.


Default Ports

ClickHouse exposes multiple interfaces.

Interface Default Port
Native TCP 9000
HTTP API 8123

For HTTP-based communication, you'll primarily work with port 8123.


Prerequisites

Before following along, ensure you have:

  • A running ClickHouse server
  • cURL installed
  • Basic SQL knowledge
  • Access to port 8123

Step 1: Verify the HTTP API

The simplest way to verify that the HTTP API is available is by checking the built-in ping endpoint.

curl http://localhost:8123/ping

Expected response:

Ok.

If you receive this response, your HTTP interface is working correctly.


Step 2: Execute Your First Query

One of the easiest ways to query ClickHouse is by passing SQL as a URL parameter.

Using GET:

curl "http://localhost:8123/?query=SELECT+version()"

Output:

25.3.1.1

Although GET works well for simple queries, POST requests are generally preferred for larger SQL statements.

Using POST:

curl -X POST http://localhost:8123/ \
  --data-binary "SELECT version()"

Output:

25.3.1.1

POST requests are cleaner and avoid URL length limitations.


Step 3: Authentication

If authentication is enabled, ClickHouse supports several methods.

URL Parameters

curl "http://localhost:8123/?user=default&password=yourpassword&query=SELECT+1"

HTTP Basic Authentication

curl -u default:yourpassword \
"http://localhost:8123/?query=SELECT+1"

HTTP Headers (Recommended)

curl http://localhost:8123/ \
-H "X-ClickHouse-User: default" \
-H "X-ClickHouse-Key: yourpassword" \
--data-binary "SELECT 1"

Using request headers is recommended because credentials aren't exposed in URLs or logs.


Step 4: Selecting a Database

Queries execute against the default database unless another database is specified.

Specify a database using the request parameter:

curl -u default:yourpassword \
"http://localhost:8123/?database=my_database" \
--data-binary "SELECT count() FROM my_table"

Or reference the database directly inside the SQL statement:

SELECT count()
FROM my_database.my_table;


Step 5: Querying Data

Executing SELECT statements is straightforward.

curl -u default:yourpassword \
http://localhost:8123/ \
--data-binary "SELECT * FROM default.products LIMIT 5"

By default, ClickHouse returns data in TabSeparated format.


Output Formats

One of the strengths of the HTTP API is its support for multiple output formats.

JSON

SELECT *
FROM default.products
FORMAT JSON

Useful for:

  • REST APIs
  • Web applications
  • JavaScript clients

CSV

SELECT *
FROM default.products
FORMAT CSV

Ideal for:

  • Excel
  • Data exports
  • ETL pipelines

JSONEachRow

SELECT *
FROM default.products
FORMAT JSONEachRow

Each row is returned as an individual JSON document, making it perfect for:

  • Streaming
  • Kafka
  • Log processing
  • Large datasets

Other Supported Formats

ClickHouse supports numerous formats including:

  • JSON
  • JSONCompact
  • JSONEachRow
  • CSV
  • TSV
  • Pretty
  • PrettyCompact
  • Parquet
  • Apache Arrow
  • TabSeparated

Choosing the appropriate format depends on how downstream systems consume the data.


Step 6: Inserting Data

The HTTP API also supports data ingestion.

Insert TabSeparated Data

curl -u default:yourpassword \
"http://localhost:8123/?query=INSERT+INTO+default.products+FORMAT+TabSeparated" \
--data-binary $'5\tMechanical Keyboard\tAccessories\n6\tMonitor 4K\tElectronics\n'


Insert CSV

curl -u default:yourpassword \
"http://localhost:8123/?query=INSERT+INTO+default.products+FORMAT+CSV" \
--data-binary @products.csv


Insert JSON

curl -u default:yourpassword \
"http://localhost:8123/?query=INSERT+INTO+default.products+FORMAT+JSONEachRow" \
--data-binary '
{"product_id":7,"name":"Webcam HD","category":"Accessories"}
{"product_id":8,"name":"Desk Lamp","category":"Furniture"}
'

This flexibility allows applications to ingest data using the format most convenient for them.


Step 7: Creating and Managing Tables

The HTTP API supports all standard Data Definition Language (DDL) operations.

Create a table:

CREATE TABLE default.logs
(
    server_id LowCardinality(String),
    level LowCardinality(String),
    message String,
    timestamp DateTime
)
ENGINE = MergeTree()
ORDER BY timestamp;

Drop a table:

DROP TABLE IF EXISTS default.logs;

Similarly, ALTER, TRUNCATE, OPTIMIZE, and other administrative statements are fully supported.


Useful HTTP Parameters

Several query parameters can simplify common tasks.

Parameter Purpose
query SQL query
user Username
password Password
database Database name
default_format Default response format
max_rows_to_read Scan limit
max_execution_time Query timeout
compress Enable response compression

These parameters help control execution behavior without modifying SQL itself.


Best Practices

To get the most out of the ClickHouse HTTP API:

  • Use POST requests for longer SQL statements.
  • Send credentials using HTTP headers instead of URLs.
  • Use JSONEachRow for streaming large datasets.
  • Set max_execution_time to prevent runaway queries.
  • Enable compression for large responses.
  • Always specify the database explicitly.
  • Use official ClickHouse client libraries in production when advanced features like connection pooling and automatic retries are required.

Following these practices results in more secure, reliable, and efficient integrations.


HTTP API vs Native Protocol

Feature HTTP API Native Protocol
Ease of Use ⭐⭐⭐⭐⭐ ⭐⭐⭐⭐
Performance ⭐⭐⭐⭐ ⭐⭐⭐⭐⭐
Driver Required No Yes
Universal Support Yes Driver Dependent
Automation Excellent Good
Bulk Inserts Good Excellent

The HTTP API is ideal for integrations, scripting, and lightweight services, while the native protocol remains the best option for performance-critical applications.


Real-World Use Cases

The ClickHouse HTTP API is commonly used for:

  • Building REST APIs
  • Internal dashboards
  • Automation scripts
  • Monitoring systems
  • CI/CD pipelines
  • Serverless applications
  • ETL workflows
  • Data export services
  • Microservices
  • Third-party integrations

Because HTTP is universally supported, integrating ClickHouse into existing systems becomes remarkably simple.


Final Thoughts

The ClickHouse HTTP API demonstrates how powerful database interactions can also be simple. By exposing SQL operations over standard HTTP, ClickHouse removes the dependency on specialized drivers and enables seamless integration with virtually any programming language or platform.

Whether you're executing queries, loading data, automating administrative tasks, or building cloud-native applications, the HTTP API offers a flexible and reliable interface that scales from quick experiments to production workloads.

As your ClickHouse deployments grow, understanding the HTTP API becomes increasingly valuable. It's a feature that bridges the gap between databases and modern software architectures, making automation, integration, and analytics significantly easier.

In the next article of this 100 Days of ClickHouse series, we'll continue exploring another powerful capability that helps you build faster, more scalable analytical systems.