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.0 el9.x86_64 pgdg 25.1 KiB pgsql_http_18-1.7.0-1PGDG.rhel9.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.0 el9.aarch64 pgdg 23.6 KiB pgsql_http_18-1.7.0-1PGDG.rhel9.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.0 el10.x86_64 pgdg 25.8 KiB pgsql_http_18-1.7.0-1PGDG.rhel10.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
pgsql_http_18 1.7.0 el10.aarch64 pgdg 24.3 KiB pgsql_http_18-1.7.0-1PGDG.rhel10.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

Sources: README, v1.7.1 release

http lets SQL code make HTTP requests through libcurl. Use it for controlled integration points such as triggers that notify an external service, SQL jobs that fetch a small remote payload, or database-side webhook calls.

CREATE EXTENSION http;

Request And Response Types

Every request uses http_request and returns http_response:

http_request(method http_method, uri varchar, headers http_header[], content_type varchar, content varchar)
http_response(status integer, content_type varchar, headers http_header[], content varchar)

Convenience wrappers call the same underlying http(http_request) function:

  • http_get(uri varchar)
  • http_get(uri varchar, data jsonb)
  • http_post(uri varchar, content varchar, content_type varchar)
  • http_post(uri varchar, data jsonb)
  • http_put(uri varchar, content varchar, content_type varchar)
  • http_patch(uri varchar, content varchar, content_type varchar)
  • http_delete(uri varchar)
  • http_head(uri varchar)

Examples

SELECT status, content_type, content
FROM http_get('https://httpbun.com/ip');

SELECT content::json->'headers'->>'Authorization'
FROM http((
  'GET',
  'https://httpbun.com/headers',
  http_headers('Authorization', 'Bearer token'),
  NULL,
  NULL
)::http_request);

SELECT status, content::json->'form' AS form
FROM http_post(
  'https://httpbun.com/post',
  jsonb_build_object('myvar', 'myval', 'foo', 'bar')
);

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

Inspect response headers by unnesting the headers array:

SELECT (unnest(headers)).*
FROM http_get('https://httpbun.com/');

Binary Content

The README warns that varchar::bytea is not safe for binary response bodies because it stops at zero-valued bytes. Use text_to_bytea(content) for response content and bytea_to_text(bytea) when sending binary request bodies.

WITH http AS (
  SELECT * FROM http_get('https://httpbingo.org/image/png')
)
SELECT content_type, length(text_to_bytea(content)) AS bytes
FROM http;

Timeout And Version Notes

pg_http 1.7.1 is a compatibility and documentation release: it adds timeout examples, adds PostgreSQL 17 wait-event hooks, and includes PostgreSQL 19 support fixes. The user-facing SQL API remains the README surface above.

Last updated on