pg_net: Async Networking
caution
The pg_net API is in alpha. Functions signatures may change.
pg_net is a PostgreSQL extension exposing a SQL interface for async networking with a focus on scalability and UX.
It differs from the http
extension in that it is asynchronous by default. This makes it useful in blocking functions (like triggers).
Enable the extension#
- Go to the Database page in the Dashboard.
- Click on Extensions in the sidebar.
- Search for "pg_net" and enable the extension.
http_get
#
Creates an HTTP GET request returning the request's ID. HTTP requests are not started until the transaction is committed.
Signature #
caution
This is a Postgres SECURITY DEFINER function.
Usage #
After triggering http_get
, use http_get_result
to get the result of the request.
http_post
#
Creates an HTTP POST request with a JSON body, returning the request's ID. HTTP requests are not started until the transaction is committed.
The body's character set encoding matches the database's server_encoding
setting.
Signature #
caution
This is a Postgres SECURITY DEFINER function
Usage #
After triggering http_post
, use http_get_result
to get the result of the request.
Examples#
Invoke a Supabase Edge Function#
Make a POST request to a Supabase Edge Function with auth header and JSON body payload:
Resources#
- Source code: github.com/supabase/pg_net
- Official Docs: supabase.github.io/pg_net