- Notifications
You must be signed in to change notification settings - Fork5
HTTP client inside your PostgreSQL. Easy to install. No compilation required. API-friendly
License
NikolayS/postgresql-http-client
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Simple HTTP client inside your PostgreSQL. Easy to install. No compilation required: no gcc, nomake && make install
. Uses only standard extension available in any popular Linux distribution. Postgres 9.6+ is required.
Works very fast (see details).BUT:
Allows GET and POSTS requests in SQL environment:
test=> \xExpanded display ison.test=>select (get).*fromhttp_client.get('http://ya.ru');-[ RECORD1 ]--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------status_code |302status_line | HTTP/1.1302 Foundheaders | {"P3P":"policyref=\"/w3c/p3p.xml\", CP=\"NON DSP ADM DEV PSD IVDo OUR IND STP PHY PRE NAV UNI\"","Date":"Sat, 29 Oct 2016 00:08:43 GMT","Server":"nginx","Expires":"Sat, 29 Oct 2016 00:08:44 GMT","Location":"https://ya.ru/","Connection":"keep-alive","Set-Cookie":"yandexuid=182183081477699724; Expires=Tue, 27-Oct-2026 00:08:43 GMT; Domain=.ya.ru; Path=/","Cache-Control":"no-cache,no-store,max-age=0,must-revalidate","Last-Modified":"Sat, 29 Oct 2016 00:08:44 GMT","Content-Length":"0"}body |is_json | f
Another example, showing work with REST API:
test=> with resultsas (select jsonb_array_elements(get.body::jsonb->'results')as rfromhttp_client.get('http://pokeapi.co/api/v2/pokemon/','{"user-agent":"test-robot"}'::jsonb))select r->>'url'as url, r->>'name'as pokenamefrom resultsorder by pokenamelimit5; url | pokename--------------------------------------+------------ http://pokeapi.co/api/v2/pokemon/15/ | beedrill http://pokeapi.co/api/v2/pokemon/9/ | blastoise http://pokeapi.co/api/v2/pokemon/1/ | bulbasaur http://pokeapi.co/api/v2/pokemon/12/ | butterfree http://pokeapi.co/api/v2/pokemon/10/ | caterpie(5 rows)
Clone the code (git clone ...
) and then execute in psql:
begin;\i/path/to/postgresql-http-client/install.sqlcommit;
\i/path/to/postgresql-http-client/uninstall.sql
About
HTTP client inside your PostgreSQL. Easy to install. No compilation required. API-friendly
Resources
License
Uh oh!
There was an error while loading.Please reload this page.