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.2
UTIL
MIT
C
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--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

Type Repo Version PG Major Compatibility Package Pattern Dependencies
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.2
18
17
16
15
14
postgresql-$v-http -
Linux / PG PG18 PG17 PG16 PG15 PG14
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
Package Version OS ORG SIZE File URL
pgsql_http_18 1.7.2 el8.x86_64 pgdg 24.9 KiB pgsql_http_18-1.7.2-2PGDG.rhel8.10.x86_64.rpm
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.2 el8.aarch64 pgdg 24.0 KiB pgsql_http_18-1.7.2-2PGDG.rhel8.10.aarch64.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.2 el9.x86_64 pgdg 25.6 KiB pgsql_http_18-1.7.2-2PGDG.rhel9.8.x86_64.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.2 el9.aarch64 pgdg 24.4 KiB pgsql_http_18-1.7.2-2PGDG.rhel9.8.aarch64.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.2 el10.x86_64 pgdg 26.2 KiB pgsql_http_18-1.7.2-2PGDG.rhel10.2.x86_64.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.2 el10.aarch64 pgdg 24.7 KiB pgsql_http_18-1.7.2-2PGDG.rhel10.2.aarch64.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.2 d12.x86_64 pgdg 45.0 KiB postgresql-18-http_1.7.2-2.pgdg12+1_amd64.deb
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.2 d12.aarch64 pgdg 43.7 KiB postgresql-18-http_1.7.2-2.pgdg12+1_arm64.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.2 d13.x86_64 pgdg 45.2 KiB postgresql-18-http_1.7.2-2.pgdg13+1_amd64.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.2 d13.aarch64 pgdg 43.8 KiB postgresql-18-http_1.7.2-2.pgdg13+1_arm64.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.2 u22.x86_64 pgdg 45.4 KiB postgresql-18-http_1.7.2-2.pgdg22.04+1_amd64.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.2 u22.aarch64 pgdg 43.8 KiB postgresql-18-http_1.7.2-2.pgdg22.04+1_arm64.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.2 u24.x86_64 pgdg 45.1 KiB postgresql-18-http_1.7.2-2.pgdg24.04+1_amd64.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.2 u24.aarch64 pgdg 43.7 KiB postgresql-18-http_1.7.2-2.pgdg24.04+1_arm64.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.2 u26.x86_64 pgdg 51.5 KiB postgresql-18-http_1.7.2-2.pgdg26.04+1_amd64.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.2 u26.aarch64 pgdg 50.2 KiB postgresql-18-http_1.7.2-2.pgdg26.04+1_arm64.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 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:

http lets PostgreSQL issue synchronous HTTP requests through libcurl. It is useful for controlled integrations and administrative calls, but the backend waits for the remote service inside the SQL statement and transaction. Restrict who can call it, set short timeouts, and do not let untrusted input choose arbitrary URLs.

Core Workflow

CREATE EXTENSION http;

SELECT status, content_type, content
FROM http_get('https://httpbingo.org/get');

Send JSON and inspect the response:

SELECT status, content::jsonb
FROM http_post(
  'https://httpbingo.org/post',
  '{"event":"invoice.paid"}',
  'application/json'
);

The generic entry point accepts a complete request:

SELECT (http((
  'GET',
  'https://httpbingo.org/headers',
  http_headers('Authorization', 'Bearer example'),
  NULL,
  NULL
)::http_request)).status;

Important Objects

  • http_request contains method, uri, headers, content_type, and content.
  • http_response contains status, content_type, headers, and content.
  • http_header, http_header(...), and http_headers(...) build request headers; unnest(response.headers) exposes response headers as rows.
  • http(...) executes a complete http_request.
  • http_get, http_post, http_put, http_patch, http_delete, and http_head are convenience wrappers.
  • urlencode(text) and urlencode(jsonb) encode query data.
  • http_set_curlopt, http_list_curlopt, and http_reset_curlopt manage supported session-level libcurl settings.

Timeouts, Connections, and Security

Each request uses a fresh connection by default. Enable persistent connections only after measuring backend lifetime and remote-server behavior:

SET http.curlopt_timeout_ms = 1000;
SET http.curlopt_connecttimeout_ms = 250;
SET http.curlopt_tcp_keepalive = 1;

The default request timeout is five seconds. A timeout raises a SQL error, so callers must handle transaction rollback. Network latency in triggers or long transactions can hold locks and exhaust database connections; prefer an outbox plus an external worker for durable asynchronous delivery.

Keep TLS verification enabled, protect credential-bearing curl settings, validate response status and content before use, and limit outbound destinations at both SQL privilege and network layers. Version 1.7.2 contains build, test, and curl-option constant maintenance relative to 1.7.1; it does not introduce a material SQL API change. The control file still declares SQL extension version 1.7.

Last updated on