http

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

Overview

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

Version

TypeRepoVersionPG VerPackageDeps
EXTMIXED1.7.11817161514pg_http-
RPMPIGSTY1.7.11817161514pgsql_http_$v-
DEBPGDG1.7.11817161514postgresql-$v-http-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
d12.x86_64
d12.aarch64
d13.x86_64
d13.aarch64
u22.x86_64
u22.aarch64
u24.x86_64
u24.aarch64
u26.x86_64
u26.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 and PIGSTY repositories are added and enabled:

pig repo add pgsql -u          # Add 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 pgsql_http_18       # PG 18
dnf install -y pgsql_http_17       # PG 17
dnf install -y pgsql_http_16       # PG 16
dnf install -y pgsql_http_15       # PG 15
dnf install -y pgsql_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

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 Modified 2026-07-02: extension update 2026-07-02 (f9f0d13)