Skip to content

http

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

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
4070
http
pg_http
1.7.2
UTIL
MIT
C
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d--
No
Yes
No
Yes
no
no
Relationships
Need By
pgmb
See Also
pg_net
pg_curl
pgjwt
pg_smtp_client
gzip
bzip
zstd
pgjq
pgmb

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXT
PGDG
1.7.2
18
17
16
15
14
pg_http-
RPM
PGDG
1.7.2
18
17
16
15
14
pgsql_http_$v-
DEB
PGDG
1.7.1
18
17
16
15
14
postgresql-$v-http-
Linux / PGPG18PG17PG16PG15PG14
el8.x86_64
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
el8.aarch64
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
el9.x86_64
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
el9.aarch64
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
el10.x86_64
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
el10.aarch64
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
d12.x86_64
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
d12.aarch64
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
d13.x86_64
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
d13.aarch64
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
u22.x86_64
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
u22.aarch64
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
u24.x86_64
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
u24.aarch64
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
u26.x86_64
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
u26.aarch64
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
PGDG 1.7.2
PackageVersionOSORGSIZEFile URL
pgsql_http_181.7.2el8.x86_64pgdg24.9 KiBpgsql_http_18-1.7.2-2PGDG.rhel8.10.x86_64.rpm
pgsql_http_181.7.1el8.x86_64pigsty29.6 KiBpgsql_http_18-1.7.1-1PIGSTY.el8.x86_64.rpm
pgsql_http_181.7.0el8.x86_64pgdg24.1 KiBpgsql_http_18-1.7.0-1PGDG.rhel8.x86_64.rpm
pgsql_http_181.7.2el8.aarch64pgdg24.0 KiBpgsql_http_18-1.7.2-2PGDG.rhel8.10.aarch64.rpm
pgsql_http_181.7.1el8.aarch64pigsty28.8 KiBpgsql_http_18-1.7.1-1PIGSTY.el8.aarch64.rpm
pgsql_http_181.7.0el8.aarch64pgdg23.2 KiBpgsql_http_18-1.7.0-1PGDG.rhel8.aarch64.rpm
pgsql_http_181.7.2el9.x86_64pgdg25.6 KiBpgsql_http_18-1.7.2-2PGDG.rhel9.8.x86_64.rpm
pgsql_http_181.7.1el9.x86_64pigsty29.5 KiBpgsql_http_18-1.7.1-1PIGSTY.el9.x86_64.rpm
pgsql_http_181.7.0el9.x86_64pgdg25.2 KiBpgsql_http_18-1.7.0-3PGDG.rhel9.8.x86_64.rpm
pgsql_http_181.7.0el9.x86_64pgdg25.1 KiBpgsql_http_18-1.7.0-1PGDG.rhel9.x86_64.rpm
pgsql_http_181.7.2el9.aarch64pgdg24.4 KiBpgsql_http_18-1.7.2-2PGDG.rhel9.8.aarch64.rpm
pgsql_http_181.7.1el9.aarch64pigsty28.6 KiBpgsql_http_18-1.7.1-1PIGSTY.el9.aarch64.rpm
pgsql_http_181.7.0el9.aarch64pgdg23.9 KiBpgsql_http_18-1.7.0-3PGDG.rhel9.8.aarch64.rpm
pgsql_http_181.7.0el9.aarch64pgdg23.6 KiBpgsql_http_18-1.7.0-1PGDG.rhel9.aarch64.rpm
pgsql_http_181.7.2el10.x86_64pgdg26.2 KiBpgsql_http_18-1.7.2-2PGDG.rhel10.2.x86_64.rpm
pgsql_http_181.7.1el10.x86_64pigsty30.0 KiBpgsql_http_18-1.7.1-1PIGSTY.el10.x86_64.rpm
pgsql_http_181.7.0el10.x86_64pgdg25.7 KiBpgsql_http_18-1.7.0-3PGDG.rhel10.2.x86_64.rpm
pgsql_http_181.7.0el10.x86_64pgdg25.8 KiBpgsql_http_18-1.7.0-1PGDG.rhel10.x86_64.rpm
pgsql_http_181.7.2el10.aarch64pgdg24.7 KiBpgsql_http_18-1.7.2-2PGDG.rhel10.2.aarch64.rpm
pgsql_http_181.7.1el10.aarch64pigsty28.8 KiBpgsql_http_18-1.7.1-1PIGSTY.el10.aarch64.rpm
pgsql_http_181.7.0el10.aarch64pgdg24.2 KiBpgsql_http_18-1.7.0-3PGDG.rhel10.2.aarch64.rpm
pgsql_http_181.7.0el10.aarch64pgdg24.3 KiBpgsql_http_18-1.7.0-1PGDG.rhel10.aarch64.rpm
postgresql-18-http1.7.2d12.x86_64pgdg45.0 KiBpostgresql-18-http_1.7.2-2.pgdg12+1_amd64.deb
postgresql-18-http1.7.1d12.x86_64pgdg45.0 KiBpostgresql-18-http_1.7.1-1.pgdg12+1_amd64.deb
postgresql-18-http1.7.1d12.x86_64pigsty44.3 KiBpostgresql-18-http_1.7.1-1PIGSTY~bookworm_amd64.deb
postgresql-18-http1.7.0d12.x86_64pgdg44.5 KiBpostgresql-18-http_1.7.0-3.pgdg12+1_amd64.deb
postgresql-18-http1.7.2d12.aarch64pgdg43.7 KiBpostgresql-18-http_1.7.2-2.pgdg12+1_arm64.deb
postgresql-18-http1.7.1d12.aarch64pgdg43.5 KiBpostgresql-18-http_1.7.1-1.pgdg12+1_arm64.deb
postgresql-18-http1.7.1d12.aarch64pigsty42.8 KiBpostgresql-18-http_1.7.1-1PIGSTY~bookworm_arm64.deb
postgresql-18-http1.7.0d12.aarch64pgdg43.1 KiBpostgresql-18-http_1.7.0-3.pgdg12+1_arm64.deb
postgresql-18-http1.7.2d13.x86_64pgdg45.2 KiBpostgresql-18-http_1.7.2-2.pgdg13+1_amd64.deb
postgresql-18-http1.7.1d13.x86_64pgdg45.2 KiBpostgresql-18-http_1.7.1-1.pgdg13+1_amd64.deb
postgresql-18-http1.7.1d13.x86_64pigsty44.4 KiBpostgresql-18-http_1.7.1-1PIGSTY~trixie_amd64.deb
postgresql-18-http1.7.0d13.x86_64pgdg44.6 KiBpostgresql-18-http_1.7.0-3.pgdg13+1_amd64.deb
postgresql-18-http1.7.2d13.aarch64pgdg43.8 KiBpostgresql-18-http_1.7.2-2.pgdg13+1_arm64.deb
postgresql-18-http1.7.1d13.aarch64pgdg43.7 KiBpostgresql-18-http_1.7.1-1.pgdg13+1_arm64.deb
postgresql-18-http1.7.1d13.aarch64pigsty43.1 KiBpostgresql-18-http_1.7.1-1PIGSTY~trixie_arm64.deb
postgresql-18-http1.7.0d13.aarch64pgdg43.2 KiBpostgresql-18-http_1.7.0-3.pgdg13+1_arm64.deb
postgresql-18-http1.7.2u22.x86_64pgdg45.4 KiBpostgresql-18-http_1.7.2-2.pgdg22.04+1_amd64.deb
postgresql-18-http1.7.1u22.x86_64pgdg45.2 KiBpostgresql-18-http_1.7.1-1.pgdg22.04+1_amd64.deb
postgresql-18-http1.7.1u22.x86_64pigsty47.2 KiBpostgresql-18-http_1.7.1-1PIGSTY~jammy_amd64.deb
postgresql-18-http1.7.0u22.x86_64pgdg44.7 KiBpostgresql-18-http_1.7.0-3.pgdg22.04+1_amd64.deb
postgresql-18-http1.7.2u22.aarch64pgdg43.8 KiBpostgresql-18-http_1.7.2-2.pgdg22.04+1_arm64.deb
postgresql-18-http1.7.1u22.aarch64pgdg43.5 KiBpostgresql-18-http_1.7.1-1.pgdg22.04+1_arm64.deb
postgresql-18-http1.7.1u22.aarch64pigsty45.8 KiBpostgresql-18-http_1.7.1-1PIGSTY~jammy_arm64.deb
postgresql-18-http1.7.0u22.aarch64pgdg43.1 KiBpostgresql-18-http_1.7.0-3.pgdg22.04+1_arm64.deb
postgresql-18-http1.7.2u24.x86_64pgdg45.1 KiBpostgresql-18-http_1.7.2-2.pgdg24.04+1_amd64.deb
postgresql-18-http1.7.1u24.x86_64pgdg45.0 KiBpostgresql-18-http_1.7.1-1.pgdg24.04+1_amd64.deb
postgresql-18-http1.7.1u24.x86_64pigsty46.3 KiBpostgresql-18-http_1.7.1-1PIGSTY~noble_amd64.deb
postgresql-18-http1.7.0u24.x86_64pgdg44.5 KiBpostgresql-18-http_1.7.0-3.pgdg24.04+1_amd64.deb
postgresql-18-http1.7.2u24.aarch64pgdg43.7 KiBpostgresql-18-http_1.7.2-2.pgdg24.04+1_arm64.deb
postgresql-18-http1.7.1u24.aarch64pgdg43.6 KiBpostgresql-18-http_1.7.1-1.pgdg24.04+1_arm64.deb
postgresql-18-http1.7.1u24.aarch64pigsty45.0 KiBpostgresql-18-http_1.7.1-1PIGSTY~noble_arm64.deb
postgresql-18-http1.7.0u24.aarch64pgdg43.0 KiBpostgresql-18-http_1.7.0-3.pgdg24.04+1_arm64.deb
postgresql-18-http1.7.2u26.x86_64pgdg51.5 KiBpostgresql-18-http_1.7.2-2.pgdg26.04+1_amd64.deb
postgresql-18-http1.7.1u26.x86_64pgdg51.6 KiBpostgresql-18-http_1.7.1-1.pgdg26.04+1_amd64.deb
postgresql-18-http1.7.1u26.x86_64pigsty54.0 KiBpostgresql-18-http_1.7.1-1PIGSTY~resolute_amd64.deb
postgresql-18-http1.7.0u26.x86_64pgdg51.2 KiBpostgresql-18-http_1.7.0-3.pgdg26.04+1_amd64.deb
postgresql-18-http1.7.2u26.aarch64pgdg50.2 KiBpostgresql-18-http_1.7.2-2.pgdg26.04+1_arm64.deb
postgresql-18-http1.7.1u26.aarch64pgdg50.2 KiBpostgresql-18-http_1.7.1-1.pgdg26.04+1_arm64.deb
postgresql-18-http1.7.1u26.aarch64pigsty52.9 KiBpostgresql-18-http_1.7.1-1PIGSTY~resolute_arm64.deb
postgresql-18-http1.7.0u26.aarch64pgdg49.9 KiBpostgresql-18-http_1.7.0-3.pgdg26.04+1_arm64.deb

Source

pig build pkg pg_http;		# build rpm

Install

Make sure PGDG repo available:

pig repo add pgdg -u    # add pgdg 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