http

HTTP client for PostgreSQL, allows web page retrieval inside the database.

Overview

PackageVersionCategoryLicenseLanguage
pg_http1.7.0UTILMITC
IDExtensionBinLibLoadCreateTrustRelocSchema
4070httpNoYesNoYesNoNo-
Relatedpg_net pg_curl pgjwt pg_smtp_client gzip bzip zstd pgjq pgmb

Version

TypeRepoVersionPG VerPackageDeps
EXTPGDG1.7.01817161514pg_http-
RPMPGDG1.7.01817161514pg_http_$v-
DEBPGDG1.7.01817161514postgresql-$v-http-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
d12.x86_64
PGDG 1.7.0
PGDG 1.7.0
PGDG 1.7.0
PGDG 1.7.0
PGDG 1.7.0
d12.aarch64
PGDG 1.7.0
PGDG 1.7.0
PGDG 1.7.0
PGDG 1.7.0
PGDG 1.7.0
d13.x86_64
PGDG 1.7.0
PGDG 1.7.0
PGDG 1.7.0
PGDG 1.7.0
PGDG 1.7.0
d13.aarch64
PGDG 1.7.0
PGDG 1.7.0
PGDG 1.7.0
PGDG 1.7.0
PGDG 1.7.0
u22.x86_64
u22.aarch64
u24.x86_64
u24.aarch64

Build

You can build the RPM packages for pg_http using pig build:

pig build pkg pg_http         # build RPM packages

Install

You can install pg_http directly. First, make sure the PGDG repository is added and enabled:

pig repo add pgdg -u          # Add PGDG repo and update cache

Install the extension using pig or apt/yum/dnf:

pig install pg_http;          # Install for current active PG version
pig ext install -y pg_http -v 18  # PG 18
pig ext install -y pg_http -v 17  # PG 17
pig ext install -y pg_http -v 16  # PG 16
pig ext install -y pg_http -v 15  # PG 15
pig ext install -y pg_http -v 14  # PG 14
dnf install -y pg_http_18       # PG 18
dnf install -y pg_http_17       # PG 17
dnf install -y pg_http_16       # PG 16
dnf install -y pg_http_15       # PG 15
dnf install -y pg_http_14       # PG 14
apt install -y postgresql-18-http   # PG 18
apt install -y postgresql-17-http   # PG 17
apt install -y postgresql-16-http   # PG 16
apt install -y postgresql-15-http   # PG 15
apt install -y postgresql-14-http   # PG 14

Create Extension:

CREATE EXTENSION http;

Usage

https://github.com/pramsey/pgsql-http

Request / Response Schema:

     Composite type "public.http_request"
    Column    |       Type        | Modifiers
--------------+-------------------+-----------
 method       | http_method       |
 uri          | character varying |
 headers      | http_header[]     |
 content_type | character varying |
 content      | character varying |

    Composite type "public.http_response"
    Column    |       Type        | Modifiers
--------------+-------------------+-----------
 status       | integer           |
 content_type | character varying |
 headers      | http_header[]     |
 content      | character varying |

Examples

Sending HTTP GET requests with SQL

CREATE EXTENSION http;

-- get content
SELECT content FROM http_get('http://httpbun.com/');

-- get status and content_type
SELECT status, content_type FROM http_get('http://httpbun.com/');

--  status |       content_type
-- --------+--------------------------
--     200 | text/html; charset=utf-8

-- get headers
SELECT (unnest(headers)).* FROM http_get('http://httpbun.com/');

--             field           |                      value
--  ---------------------------+--------------------------------------------------
--  Location                  | https://httpbun.com/
--  Date                      | Mon, 04 Nov 2024 09:00:36 GMT
--  Content-Length            | 0
--  Connection                | close
--  alt-svc                   | h3=":443"; ma=2592000
--  content-security-policy   | frame-ancestors 'none'
--  content-type              | text/html
--  date                      | Mon, 04 Nov 2024 09:00:37 GMT
--  strict-transport-security | max-age=31536000; includeSubDomains; preload
--  x-content-type-options    | nosniff
--  x-powered-by              | httpbun/af040d24038613575a85f74c2283ae79f8169927
--  (11 rows)
SELECT status, content::json->'form' AS form FROM http_post('http://httpbun.com/post', jsonb_build_object('myvar','myval','foo','bar'));

Issue http put requests:

SELECT status, content_type, content::json->>'data' AS data
  FROM http_put('http://httpbun.com/put', 'some text', 'text/plain');


--  status |   content_type   |   data
-- --------+------------------+-----------
--  200 | application/json | some text

Issue http post request:


Last Modified 2026-03-12: add pg extension catalog (95749bf)