DuckDB HTTP Client Extension
Installing and Loading
INSTALL http_client FROM community;
LOAD http_client;
Example
-- GET Request Example w/ JSON Parsing
D WITH __input AS (
SELECT
http_get(
'https://httpbin.org/delay/0'
) AS data
),
__features AS (
SELECT
unnest( from_json((data::JSON)->'headers', '{"Host": "VARCHAR"}') )
AS features
FROM
__input
)
SELECT
__features.Host AS host,
FROM
__features
;
┌─────────────┐
│ host │
│ varchar │
├─────────────┤
│ 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 {}
) AS data
),
__features AS (
SELECT
unnest( from_json((data::JSON)->'headers', '{"Host": "VARCHAR"}') )
AS features
FROM
__input
)
SELECT
__features.Host AS host,
FROM
__features
;
┌─────────────┐
│ host │
│ varchar │
├─────────────┤
│ httpbin.org │
└─────────────┘
About http_client
This extension is experimental and potentially unstable. Do not use it in production yet.
Added Functions
function_name | function_type | description | comment | example |
---|---|---|---|---|
http_get | scalar | |||
http_post | scalar |