Search Shortcut cmd + k | ctrl + k
http_client

DuckDB HTTP Client Extension

Installing and Loading

INSTALL http_client FROM community;
LOAD http_client;

Example

-- GET Request Example w/ JSON Parsing
WITH __input AS (
  SELECT
    http_get(
        'https://httpbin.org/delay/0',
        headers => MAP {
          'accept': 'application/json',
        },
        params => MAP {
          'limit': 1
        }
    ) AS res
),
__response AS (
  SELECT
    (res->>'status')::INT AS status,
    (res->>'reason') AS reason,
    unnest( from_json(((res->>'body')::JSON)->'headers', '{"Host": "VARCHAR"}') ) AS features
  FROM
    __input
)
SELECT
  __response.status,
  __response.reason,
  __response.Host AS host
FROM
  __response
;
┌────────┬─────────┬─────────────┐
 status  reason      host     
 int32   varchar    varchar   
├────────┼─────────┼─────────────┤
    200  OK       httpbin.org 
└────────┴─────────┴─────────────┘

-- POST Request Example w/ Headers and Parameters
WITH __input AS (
SELECT
  http_post(
      'https://httpbin.org/delay/0',
      headers => MAP {
        'accept': 'application/json',
      },
      params => MAP {
        'limit': 1
      }
  ) AS res
),
__response AS (
  SELECT
    (res->>'status')::INT AS status,
    (res->>'reason') AS reason,
    unnest( from_json(((res->>'body')::JSON)->'headers', '{"Host": "VARCHAR"}') ) AS features
  FROM
    __input
)
SELECT
  __response.status,
  __response.reason,
  __response.Host AS host,
FROM
  __response
;
┌────────┬─────────┬─────────────┐
 status  reason      host     
 int32   varchar    varchar   
├────────┼─────────┼─────────────┤
    200  OK       httpbin.org 
└────────┴─────────┴─────────────┘

About http_client

The HTTP Client Extension is experimental, use at your own risk!

Added Functions

function_name function_type description comment examples
http_get scalar NULL NULL  
http_head scalar NULL NULL  
http_post scalar NULL NULL  
http_post_form scalar NULL NULL  

Overloaded Functions

This extension does not add any function overloads.

Added Types

This extension does not add any types.

Added Settings

This extension does not add any settings.