http extension allows you to call RESTful endpoints within Postgres.
Let's cover some basic concepts:
- REST: stands for REpresentational State Transfer. It's simply a way to request data from external services.
- RESTful APIs are servers which accept HTTP "calls". The calls are typically:
GET− Read only access to a resource.
POST− Creates a new resource.
DELETE− Removes a resource.
PUT− Updates an existing resource or creates a new resource.
You can use the
http extension to make these network requests from Postgres.
Even though the SQL code is
create extension, this is the equivalent of "enabling the extension".
To disable an extension you can call
It's good practice to create the extension within a separate schema (like
extensions) to keep your database clean.
While the main usage is simply
http('http_request'), there are 5 wrapper functions for specific functionality:
A successful call to a web URL from the
http extension returns a record with the following fields:
content_type: character varying
content: character varying. Typically you would want to cast this to
jsonbusing the format