Search Shortcut cmd + k | ctrl + k
httpserver

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'
  }
);

About httpserver

This extension is experimental and potentially unstable. Do not use it in production.

Added Functions

function_name function_type description comment example
httpserve_start scalar      
httpserve_stop scalar