Skip to content
http

http

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

Overview

ID Extension Package Version Category License Language
4070
http
pg_http
1.7.1
UTIL
MIT
C
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--s-d--
No
Yes
No
Yes
no
no
Relationships
See Also
pg_net
pg_curl
pgjwt
pg_smtp_client
gzip
bzip
zstd
pgjq
pgmb

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT
MIXED
1.7.1
18
17
16
15
14
pg_http -
RPM
PIGSTY
1.7.1
18
17
16
15
14
pgsql_http_$v -
DEB
PGDG
1.7.1
18
17
16
15
14
postgresql-$v-http -
Linux / PG PG18 PG17 PG16 PG15 PG14
el8.x86_64
PIGSTY 1.7.1
PIGSTY 1.7.1
PIGSTY 1.7.1
PIGSTY 1.7.1
PIGSTY 1.7.1
el8.aarch64
PIGSTY 1.7.1
PIGSTY 1.7.1
PIGSTY 1.7.1
PIGSTY 1.7.1
PIGSTY 1.7.1
el9.x86_64
PIGSTY 1.7.1
PIGSTY 1.7.1
PIGSTY 1.7.1
PIGSTY 1.7.1
PIGSTY 1.7.1
el9.aarch64
PIGSTY 1.7.1
PIGSTY 1.7.1
PIGSTY 1.7.1
PIGSTY 1.7.1
PIGSTY 1.7.1
el10.x86_64
PIGSTY 1.7.1
PIGSTY 1.7.1
PIGSTY 1.7.1
PIGSTY 1.7.1
PIGSTY 1.7.1
el10.aarch64
PIGSTY 1.7.1
PIGSTY 1.7.1
PIGSTY 1.7.1
PIGSTY 1.7.1
PIGSTY 1.7.1
d12.x86_64
PGDG 1.7.1
PGDG 1.7.1
PGDG 1.7.1
PGDG 1.7.1
PGDG 1.7.1
d12.aarch64
PGDG 1.7.1
PGDG 1.7.1
PGDG 1.7.1
PGDG 1.7.1
PGDG 1.7.1
d13.x86_64
PGDG 1.7.1
PGDG 1.7.1
PGDG 1.7.1
PGDG 1.7.1
PGDG 1.7.1
d13.aarch64
PGDG 1.7.1
PGDG 1.7.1
PGDG 1.7.1
PGDG 1.7.1
PGDG 1.7.1
u22.x86_64
PGDG 1.7.1
PGDG 1.7.1
PGDG 1.7.1
PGDG 1.7.1
PGDG 1.7.1
u22.aarch64
PGDG 1.7.1
PGDG 1.7.1
PGDG 1.7.1
PGDG 1.7.1
PGDG 1.7.1
u24.x86_64
PGDG 1.7.1
PGDG 1.7.1
PGDG 1.7.1
PGDG 1.7.1
PGDG 1.7.1
u24.aarch64
PGDG 1.7.1
PGDG 1.7.1
PGDG 1.7.1
PGDG 1.7.1
PGDG 1.7.1
u26.x86_64
PGDG 1.7.1
PGDG 1.7.1
PGDG 1.7.1
PGDG 1.7.1
PGDG 1.7.1
u26.aarch64
PGDG 1.7.1
PGDG 1.7.1
PGDG 1.7.1
PGDG 1.7.1
PGDG 1.7.1
Package Version OS ORG SIZE File URL
pgsql_http_18 1.7.1 el8.x86_64 pigsty 29.6 KiB pgsql_http_18-1.7.1-1PIGSTY.el8.x86_64.rpm
pgsql_http_18 1.7.0 el8.x86_64 pgdg 24.1 KiB pgsql_http_18-1.7.0-1PGDG.rhel8.x86_64.rpm
pgsql_http_18 1.7.1 el8.aarch64 pigsty 28.8 KiB pgsql_http_18-1.7.1-1PIGSTY.el8.aarch64.rpm
pgsql_http_18 1.7.0 el8.aarch64 pgdg 23.2 KiB pgsql_http_18-1.7.0-1PGDG.rhel8.aarch64.rpm
pgsql_http_18 1.7.1 el9.x86_64 pigsty 29.5 KiB pgsql_http_18-1.7.1-1PIGSTY.el9.x86_64.rpm
pgsql_http_18 1.7.0 el9.x86_64 pgdg 25.2 KiB pgsql_http_18-1.7.0-3PGDG.rhel9.8.x86_64.rpm
pgsql_http_18 1.7.1 el9.aarch64 pigsty 28.6 KiB pgsql_http_18-1.7.1-1PIGSTY.el9.aarch64.rpm
pgsql_http_18 1.7.0 el9.aarch64 pgdg 23.9 KiB pgsql_http_18-1.7.0-3PGDG.rhel9.8.aarch64.rpm
pgsql_http_18 1.7.1 el10.x86_64 pigsty 30.0 KiB pgsql_http_18-1.7.1-1PIGSTY.el10.x86_64.rpm
pgsql_http_18 1.7.0 el10.x86_64 pgdg 25.7 KiB pgsql_http_18-1.7.0-3PGDG.rhel10.2.x86_64.rpm
pgsql_http_18 1.7.1 el10.aarch64 pigsty 28.8 KiB pgsql_http_18-1.7.1-1PIGSTY.el10.aarch64.rpm
pgsql_http_18 1.7.0 el10.aarch64 pgdg 24.2 KiB pgsql_http_18-1.7.0-3PGDG.rhel10.2.aarch64.rpm
postgresql-18-http 1.7.1 d12.x86_64 pgdg 45.0 KiB postgresql-18-http_1.7.1-1.pgdg12+1_amd64.deb
postgresql-18-http 1.7.1 d12.x86_64 pigsty 44.3 KiB postgresql-18-http_1.7.1-1PIGSTY~bookworm_amd64.deb
postgresql-18-http 1.7.0 d12.x86_64 pgdg 44.5 KiB postgresql-18-http_1.7.0-3.pgdg12+1_amd64.deb
postgresql-18-http 1.7.1 d12.aarch64 pgdg 43.5 KiB postgresql-18-http_1.7.1-1.pgdg12+1_arm64.deb
postgresql-18-http 1.7.1 d12.aarch64 pigsty 42.8 KiB postgresql-18-http_1.7.1-1PIGSTY~bookworm_arm64.deb
postgresql-18-http 1.7.0 d12.aarch64 pgdg 43.1 KiB postgresql-18-http_1.7.0-3.pgdg12+1_arm64.deb
postgresql-18-http 1.7.1 d13.x86_64 pgdg 45.2 KiB postgresql-18-http_1.7.1-1.pgdg13+1_amd64.deb
postgresql-18-http 1.7.1 d13.x86_64 pigsty 44.4 KiB postgresql-18-http_1.7.1-1PIGSTY~trixie_amd64.deb
postgresql-18-http 1.7.0 d13.x86_64 pgdg 44.6 KiB postgresql-18-http_1.7.0-3.pgdg13+1_amd64.deb
postgresql-18-http 1.7.1 d13.aarch64 pgdg 43.7 KiB postgresql-18-http_1.7.1-1.pgdg13+1_arm64.deb
postgresql-18-http 1.7.1 d13.aarch64 pigsty 43.1 KiB postgresql-18-http_1.7.1-1PIGSTY~trixie_arm64.deb
postgresql-18-http 1.7.0 d13.aarch64 pgdg 43.2 KiB postgresql-18-http_1.7.0-3.pgdg13+1_arm64.deb
postgresql-18-http 1.7.1 u22.x86_64 pgdg 45.2 KiB postgresql-18-http_1.7.1-1.pgdg22.04+1_amd64.deb
postgresql-18-http 1.7.1 u22.x86_64 pigsty 47.2 KiB postgresql-18-http_1.7.1-1PIGSTY~jammy_amd64.deb
postgresql-18-http 1.7.0 u22.x86_64 pgdg 44.7 KiB postgresql-18-http_1.7.0-3.pgdg22.04+1_amd64.deb
postgresql-18-http 1.7.1 u22.aarch64 pgdg 43.5 KiB postgresql-18-http_1.7.1-1.pgdg22.04+1_arm64.deb
postgresql-18-http 1.7.1 u22.aarch64 pigsty 45.8 KiB postgresql-18-http_1.7.1-1PIGSTY~jammy_arm64.deb
postgresql-18-http 1.7.0 u22.aarch64 pgdg 43.1 KiB postgresql-18-http_1.7.0-3.pgdg22.04+1_arm64.deb
postgresql-18-http 1.7.1 u24.x86_64 pgdg 45.0 KiB postgresql-18-http_1.7.1-1.pgdg24.04+1_amd64.deb
postgresql-18-http 1.7.1 u24.x86_64 pigsty 46.3 KiB postgresql-18-http_1.7.1-1PIGSTY~noble_amd64.deb
postgresql-18-http 1.7.0 u24.x86_64 pgdg 44.5 KiB postgresql-18-http_1.7.0-3.pgdg24.04+1_amd64.deb
postgresql-18-http 1.7.1 u24.aarch64 pgdg 43.6 KiB postgresql-18-http_1.7.1-1.pgdg24.04+1_arm64.deb
postgresql-18-http 1.7.1 u24.aarch64 pigsty 45.0 KiB postgresql-18-http_1.7.1-1PIGSTY~noble_arm64.deb
postgresql-18-http 1.7.0 u24.aarch64 pgdg 43.0 KiB postgresql-18-http_1.7.0-3.pgdg24.04+1_arm64.deb
postgresql-18-http 1.7.1 u26.x86_64 pgdg 51.6 KiB postgresql-18-http_1.7.1-1.pgdg26.04+1_amd64.deb
postgresql-18-http 1.7.1 u26.x86_64 pigsty 54.0 KiB postgresql-18-http_1.7.1-1PIGSTY~resolute_amd64.deb
postgresql-18-http 1.7.0 u26.x86_64 pgdg 51.2 KiB postgresql-18-http_1.7.0-3.pgdg26.04+1_amd64.deb
postgresql-18-http 1.7.1 u26.aarch64 pgdg 50.2 KiB postgresql-18-http_1.7.1-1.pgdg26.04+1_arm64.deb
postgresql-18-http 1.7.1 u26.aarch64 pigsty 52.9 KiB postgresql-18-http_1.7.1-1PIGSTY~resolute_arm64.deb
postgresql-18-http 1.7.0 u26.aarch64 pgdg 49.9 KiB postgresql-18-http_1.7.0-3.pgdg26.04+1_arm64.deb

Source

pig build pkg pg_http;		# build rpm

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pg_http;		# install via package name, for the active PG version
pig install http;		# install by extension name, for the current active PG version

pig install http -v 18;   # install for PG 18
pig install http -v 17;   # install for PG 17
pig install http -v 16;   # install for PG 16
pig install http -v 15;   # install for PG 15
pig install http -v 14;   # install for PG 14

Create this extension with:

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 updated on