Skip to content

HTTP Client

Make HTTP GET and POST requests directly from DuckDB SQL.

359,738
extension loads Β· last 90 days
On this page

Technical Overview

A REST call and a row, one SELECT apart

How it works

  • β€’ Synchronous and blocking: DuckDB stalls on each call until the response arrives or the underlying request fails β€” there is no per-row timeout knob and no async dispatch. A slow endpoint slows the whole query, and rows are processed in whatever order DuckDB chooses to evaluate the scalar.
  • β€’ One call per row: Per-row enrichment issues exactly one HTTP request per input row, sequentially, with no connection reuse exposed at the SQL layer. Fine for tens or hundreds of rows; for tens of thousands it is slow and very likely to get rate-limited upstream. Pre-aggregate to distinct keys or cache responses into a table with CREATE TABLE AS before joining at scale.
  • β€’ JSON response struct: Every call returns a JSON object shaped {status, reason, body} β€” status is the numeric HTTP code, reason is the HTTP reason phrase ("OK", "Not Found"), and body is always a string. Pull fields out with ->>; to drill into a JSON response body, cast it first: ((res->>'body')::JSON)->>'$.field'.
  • β€’ Headers and params are MAPs: Headers and POST parameters are passed as DuckDB MAP literals β€” MAP{'key': 'value', ...}. Headers go on the wire as-is; how the params map is encoded into the body (JSON vs. URL-encoded form) depends on which POST function you call.

Scope and caveats

  • β€’ Experimental status: Marked experimental by the upstream README β€” "USE AT YOUR OWN RISK!". Pin a known-good extension version in any pipeline that depends on it.
  • β€’ GET and POST only: The documented surface covers GET and POST (JSON or form-encoded) β€” no PUT, PATCH, or DELETE. For other HTTP methods, shell out to curl via shellfs.
  • β€’ No retries, backoff, or streaming: The request is issued once and the entire response body is buffered into memory β€” there is no automatic retry, no backoff, and no streaming read of large responses. Build retry/backoff in your application layer, and prefer shellfs + curl piped through read_csv / read_json when a response is too big to hold in memory.
  • β€’ Credentials are visible in the query plan: Any token or secret inlined into a headers or params map appears in the cached query plan and EXPLAIN output. Source credentials from the environment with getenv and bind them through SET VARIABLE β€” getenv resolves at parse time, so the literal value never lands in a cached plan or session log.

Deep Dive

Technical Details

Install

INSTALL http_client FROM community;
LOAD http_client;

Quick Start

GET a URL and read the status code

SELECT (http_get('https://httpbin.org/get')->>'status')::INT AS status;

POST a JSON body

SELECT http_post(
  'https://httpbin.org/post',
  headers => MAP{'accept': 'application/json'},
  params  => MAP{'name': 'alice'}
);

POST as application/x-www-form-urlencoded

SELECT http_post_form(
  'https://httpbin.org/post',
  headers => MAP{},
  params  => MAP{'limit': '10'}
);

Reference

Extension Contents

Quick reference to all available functions and settings organized by category.

Name Description
Requests
http_get() Issue an HTTP GET against url and return the response as JSON.
http_head() Issue an HTTP HEAD request β€” same response metadata as a GET, but without a body.
http_post() Issue an HTTP POST with the params map JSON-encoded as the request body.
http_post_form() Issue an HTTP POST with the params map encoded as application/x-www-form-urlencoded β€” the body shape used by HTML forms, many older REST APIs, and OAuth 2.0 token endpoints.

API Reference

Function Documentation

Practical Examples

Cookbook

Real-world recipes and patterns for common use cases.

Platform Support

Compatibility

Extension availability may vary by platform and DuckDB version. Check below to ensure this extension supports your environment before installation.

Quick Facts

Release status Experimental
Software License MIT
Pricing Free
Written In C++
Source Available Yes
View on GitHub
Usage
359,738
loads Β· last 90 days

Platforms

  • Linux x86_64 aarch64
  • Linux (musl) Not available
  • macOS Intel Apple Silicon
  • Windows x86_64
  • WASM Not available
Compiled binary sizes
Platform Architecture Size
Linux x86_64 6.10 MB
Linux aarch64 6.03 MB
macOS Intel 3.60 MB
macOS Apple Silicon 3.74 MB
Windows x86_64 9.35 MB

Compressed download size from the Haybarn extension repository.

DuckDB & Haybarn

Release calendar