DuckDB HTTP API Server Extension
Installing and Loading
INSTALL httpserver FROM community;
LOAD httpserver;
Example
-- Start a DuckDB HTTP API Server with parameters
D SELECT httpserve_start('0.0.0.0', 9999, 'user:pass');
┌───────────────────────────────────────────────┐
│ httpserve_start('0.0.0.0', 9999, 'user:pass') │
│ varchar │
├───────────────────────────────────────────────┤
│ HTTP server started on 0.0.0.0:9999 │
└───────────────────────────────────────────────┘
-- Browse to your DuckDB HTTP API endpoint to Query using the embedded interface
-- Query your DuckDB HTTP API Server using curl or any other client w/ HTTP Basic Auth
curl -X POST -d "LOAD chsql; SELECT *, uuid() FROM numbers(10)" "http://user:pass@localhost:9999/"
-- Query your DuckDB HTTP API Server using curl or any other client w/ X-API-Key header
curl -X POST --header "X-API-Key: secretkey" -d "LOAD chsql; SELECT *, uuid() FROM numbers(10)" "http://localhost:9999/"
-- Query your DuckDB HTTP API Server using DuckDB HTTPFS extension w/ Header Authentication
D CREATE SECRET extra_http_headers (
TYPE HTTP,
EXTRA_HTTP_HEADERS MAP{
'X-API-Key': 'secretkey'
}
);
-- DuckDB API Server settings
* If you want no authentication, just pass an empty string as parameter.
* If you want the API run in foreground set `DUCKDB_HTTPSERVER_FOREGROUND=1`
* If you want logs set `DUCKDB_HTTPSERVER_DEBUG=1` or `DUCKDB_HTTPSERVER_SYSLOG=1`

About httpserver
DuckDB HTTP Server Extension
This extension transforms DuckDB instances into tiny multi-player HTTP OLAP API services.
Supports Authentication (Basic Auth or X-Token) and includes the play SQL user interface.
Features
- Turn any DuckDB instance into an HTTP OLAP API Server
- Use the embedded Web User Interface to query and visualize data
- Work with local and remote datasets including MotherDuck 🐤
- 100% Opensource, ready to use and extend by the Community!
This extension is experimental and potentially unstable. Do not use it in production.
Added Functions
function_name | function_type | description | comment | examples |
---|---|---|---|---|
httpserve_start | scalar | NULL | NULL | [] |
httpserve_stop | scalar | NULL | NULL | [] |