pg_net

Async HTTP Requests

Overview

PackageVersionCategoryLicenseLanguage
pg_net0.20.2UTILApache-2.0C
IDExtensionBinLibLoadCreateTrustRelocSchema
4080pg_netNoYesYesYesNoNonet
Relatedhttp pg_curl pgjwt pg_smtp_client gzip bzip zstd pgjq

patched 0.9.2 on el8/el9

Version

TypeRepoVersionPG VerPackageDeps
EXTPIGSTY0.20.21817161514pg_net-
RPMPIGSTY0.20.21817161514pg_net_$v-
DEBPIGSTY0.20.21817161514postgresql-$v-pg-net-
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
PIGSTY 0.9.2
PIGSTY 0.9.2
PIGSTY 0.9.2
PIGSTY 0.9.2
PIGSTY 0.9.2
u24.x86_64
u24.aarch64
PIGSTY 0.20.2
PIGSTY 0.20.2
PIGSTY 0.20.2
PIGSTY 0.20.2
PIGSTY 0.20.2

Build

You can build the RPM / DEB packages for pg_net using pig build:

pig build pkg pg_net         # build RPM / DEB packages

Install

You can install pg_net 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_net;          # Install for current active PG version
pig ext install -y pg_net -v 18  # PG 18
pig ext install -y pg_net -v 17  # PG 17
pig ext install -y pg_net -v 16  # PG 16
pig ext install -y pg_net -v 15  # PG 15
pig ext install -y pg_net -v 14  # PG 14
dnf install -y pg_net_18       # PG 18
dnf install -y pg_net_17       # PG 17
dnf install -y pg_net_16       # PG 16
dnf install -y pg_net_15       # PG 15
dnf install -y pg_net_14       # PG 14
apt install -y postgresql-18-pg-net   # PG 18
apt install -y postgresql-17-pg-net   # PG 17
apt install -y postgresql-16-pg-net   # PG 16
apt install -y postgresql-15-pg-net   # PG 15
apt install -y postgresql-14-pg-net   # PG 14

Preload:

shared_preload_libraries = 'pg_net';

Create Extension:

CREATE EXTENSION pg_net;

Usage

pg_net: Async HTTP/HTTPS requests in SQL

The extension requires shared_preload_libraries = 'pg_net' in postgresql.conf.

GET Request

SELECT net.http_get('https://postman-echo.com/get?foo=bar') AS request_id;

With URL-encoded params and headers:

SELECT net.http_get(
  'https://postman-echo.com/get',
  params := '{"foo": "bar"}'::JSONB,
  headers := '{"API-KEY": "<key>"}'::JSONB
) AS request_id;

POST Request

SELECT net.http_post(
    'https://postman-echo.com/post',
    '{"key": "value"}'::JSONB,
    headers := '{"Content-Type": "application/json"}'::JSONB
) AS request_id;

Send a table row as payload:

WITH row AS (SELECT * FROM my_table LIMIT 1)
SELECT net.http_post(
    'https://api.example.com/data',
    to_jsonb(row.*)
) AS request_id
FROM row;

DELETE Request

SELECT net.http_delete('https://api.example.com/resource/42') AS request_id;

Checking Responses

SELECT * FROM net._http_response;

Configuration

SHOW pg_net.batch_size;       -- default: 200, max rows processed per cycle
SHOW pg_net.ttl;              -- default: 6 hours, response retention time
SHOW pg_net.database_name;    -- default: 'postgres'

Modify settings:

ALTER SYSTEM SET pg_net.ttl TO '1 hour';
ALTER SYSTEM SET pg_net.batch_size TO 500;
SELECT pg_reload_conf();

Last Modified 2026-03-12: add pg extension catalog (95749bf)