Skip to content
pg_net

pg_net

pg_net : Async HTTP Requests

Overview

ID Extension Package Version Category License Language
4080
pg_net
pg_net
0.20.2
UTIL
Apache-2.0
C
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--sLd--
No
Yes
Yes
Yes
no
no
Relationships
Schemas net
Need By
pgmb
See Also
http
pg_curl
pgjwt
pg_smtp_client
gzip
bzip
zstd
pgjq

patched 0.9.2 on el8/el9

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
EXT
PIGSTY
0.20.2
18
17
16
15
14
pg_net -
RPM
PIGSTY
0.20.2
18
17
16
15
14
pg_net_$v -
DEB
PIGSTY
0.20.2
18
17
16
15
14
postgresql-$v-pg-net -
Linux / PG PG18 PG17 PG16 PG15 PG14
el8.x86_64
PIGSTY 0.9.2
PIGSTY 0.9.2
PIGSTY 0.9.2
PIGSTY 0.9.2
PIGSTY 0.9.2
el8.aarch64
PIGSTY 0.9.2
PIGSTY 0.9.2
PIGSTY 0.9.2
PIGSTY 0.9.2
PIGSTY 0.9.2
el9.x86_64
PIGSTY 0.9.2
PIGSTY 0.9.2
PIGSTY 0.9.2
PIGSTY 0.9.2
PIGSTY 0.9.2
el9.aarch64
PIGSTY 0.9.2
PIGSTY 0.9.2
PIGSTY 0.9.2
PIGSTY 0.9.2
PIGSTY 0.9.2
el10.x86_64
PIGSTY 0.20.2
PIGSTY 0.20.2
PIGSTY 0.20.2
PIGSTY 0.20.2
PIGSTY 0.20.2
el10.aarch64
PIGSTY 0.20.2
PIGSTY 0.20.2
PIGSTY 0.20.2
PIGSTY 0.20.2
PIGSTY 0.20.2
d12.x86_64
PIGSTY 0.20.2
PIGSTY 0.20.2
PIGSTY 0.20.2
PIGSTY 0.20.2
PIGSTY 0.20.2
d12.aarch64
PIGSTY 0.20.2
PIGSTY 0.20.2
PIGSTY 0.20.2
PIGSTY 0.20.2
PIGSTY 0.20.2
d13.x86_64
PIGSTY 0.20.2
PIGSTY 0.20.2
PIGSTY 0.20.2
PIGSTY 0.20.2
PIGSTY 0.20.2
d13.aarch64
PIGSTY 0.20.2
PIGSTY 0.20.2
PIGSTY 0.20.2
PIGSTY 0.20.2
PIGSTY 0.20.2
u22.x86_64
PIGSTY 0.9.2
PIGSTY 0.9.2
PIGSTY 0.9.2
PIGSTY 0.9.2
PIGSTY 0.9.2
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
PIGSTY 0.20.2
PIGSTY 0.20.2
PIGSTY 0.20.2
PIGSTY 0.20.2
PIGSTY 0.20.2
u24.aarch64
PIGSTY 0.20.2
PIGSTY 0.20.2
PIGSTY 0.20.2
PIGSTY 0.20.2
PIGSTY 0.20.2
u26.x86_64
PIGSTY 0.20.2
PIGSTY 0.20.2
PIGSTY 0.20.2
PIGSTY 0.20.2
PIGSTY 0.20.2
u26.aarch64
PIGSTY 0.20.2
PIGSTY 0.20.2
PIGSTY 0.20.2
PIGSTY 0.20.2
PIGSTY 0.20.2
Package Version OS ORG SIZE File URL
pg_net_18 0.9.2 el8.x86_64 pigsty 27.1 KiB pg_net_18-0.9.2-2PIGSTY.el8.x86_64.rpm
pg_net_18 0.9.2 el8.aarch64 pigsty 26.9 KiB pg_net_18-0.9.2-2PIGSTY.el8.aarch64.rpm
pg_net_18 0.9.2 el9.x86_64 pigsty 26.8 KiB pg_net_18-0.9.2-2PIGSTY.el9.x86_64.rpm
pg_net_18 0.9.2 el9.aarch64 pigsty 26.5 KiB pg_net_18-0.9.2-2PIGSTY.el9.aarch64.rpm
pg_net_18 0.20.2 el10.x86_64 pigsty 36.1 KiB pg_net_18-0.20.2-1PIGSTY.el10.x86_64.rpm
pg_net_18 0.20.0 el10.x86_64 pgdg 33.9 KiB pg_net_18-0.20.0-1PGDG.rhel10.x86_64.rpm
pg_net_18 0.19.7 el10.x86_64 pgdg 33.0 KiB pg_net_18-0.19.7-1PGDG.rhel10.x86_64.rpm
pg_net_18 0.20.2 el10.aarch64 pigsty 36.4 KiB pg_net_18-0.20.2-1PIGSTY.el10.aarch64.rpm
pg_net_18 0.20.0 el10.aarch64 pgdg 33.4 KiB pg_net_18-0.20.0-1PGDG.rhel10.aarch64.rpm
pg_net_18 0.19.7 el10.aarch64 pgdg 32.5 KiB pg_net_18-0.19.7-1PGDG.rhel10.aarch64.rpm
postgresql-18-pg-net 0.20.2 d12.x86_64 pigsty 60.2 KiB postgresql-18-pg-net_0.20.2-1PIGSTY~bookworm_amd64.deb
postgresql-18-pg-net 0.20.2 d12.aarch64 pigsty 58.6 KiB postgresql-18-pg-net_0.20.2-1PIGSTY~bookworm_arm64.deb
postgresql-18-pg-net 0.20.2 d13.x86_64 pigsty 60.3 KiB postgresql-18-pg-net_0.20.2-1PIGSTY~trixie_amd64.deb
postgresql-18-pg-net 0.20.2 d13.aarch64 pigsty 58.8 KiB postgresql-18-pg-net_0.20.2-1PIGSTY~trixie_arm64.deb
postgresql-18-pg-net 0.9.2 u22.x86_64 pigsty 41.5 KiB postgresql-18-pg-net_0.9.2-2PIGSTY~jammy_amd64.deb
postgresql-18-pg-net 0.9.2 u22.aarch64 pigsty 40.9 KiB postgresql-18-pg-net_0.9.2-2PIGSTY~jammy_arm64.deb
postgresql-18-pg-net 0.20.2 u24.x86_64 pigsty 62.2 KiB postgresql-18-pg-net_0.20.2-1PIGSTY~noble_amd64.deb
postgresql-18-pg-net 0.20.2 u24.aarch64 pigsty 61.1 KiB postgresql-18-pg-net_0.20.2-1PIGSTY~noble_arm64.deb
postgresql-18-pg-net 0.20.2 u26.x86_64 pigsty 61.9 KiB postgresql-18-pg-net_0.20.2-1PIGSTY~resolute_amd64.deb
postgresql-18-pg-net 0.20.2 u26.aarch64 pigsty 60.8 KiB postgresql-18-pg-net_0.20.2-1PIGSTY~resolute_arm64.deb

Source

pig build pkg pg_net;		# build rpm/deb

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_net;		# install via package name, for the active PG version

pig install pg_net -v 18;   # install for PG 18
pig install pg_net -v 17;   # install for PG 17
pig install pg_net -v 16;   # install for PG 16
pig install pg_net -v 15;   # install for PG 15
pig install pg_net -v 14;   # install for PG 14

Config this extension to shared_preload_libraries:

shared_preload_libraries = 'pg_net';

Create this extension with:

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 updated on