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
|
Source
pig build pkg pg_net; # build rpm/debInstall
Make sure PGDG and PIGSTY repo available:
pig repo add pgsql -u # add both repo and update cacheInstall 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 14Config this extension to shared_preload_libraries:
shared_preload_libraries = 'pg_net';Create this extension with:
CREATE EXTENSION pg_net;Usage
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