Skip to content
Discord Get Started

http — HTTP Client

Make HTTP requests directly from SQL.

SQL
CREATE EXTENSION http;
SQL
-- GET request
SELECT http_get('https://api.example.com/data');
-- POST request with JSON body
SELECT http_post(
'https://api.example.com/endpoint',
'{"key": "value"}',
'application/json'
);
FunctionDescription
http_get(url)HTTP GET request
http_post(url, body, content_type)HTTP POST request
http_put(url, body, content_type)HTTP PUT request
http_delete(url)HTTP DELETE request
http_head(url)HTTP HEAD request
http_patch(url, body, content_type)HTTP PATCH request
SQL
SELECT
(http_get('https://api.ipify.org?format=json'))::json->>'ip' as my_ip;

The http functions return a composite type with these fields:

FieldTypeDescription
statusINTHTTP status code (200, 404, etc.)
content_typeTEXTResponse Content-Type header
headersJSONBAll response headers
contentTEXTResponse body
SQL
-- Send alert to webhook
SELECT http_post(
'https://hooks.slack.com/services/xxx/yyy/zzz',
'{"text": "Database backup completed!"}',
'application/json'
);
SQL
-- Health check multiple endpoints
SELECT
url,
(http_head(url)).status as status
FROM (VALUES
('https://api.example.com/health'),
('https://db9.ai'),
('https://google.com')
) t(url);

Security: DB9 has built-in SSRF protection. Requests to internal/private IP ranges are blocked.