SlideShare a Scribd company logo
PGDay.IT 2016 – 13 Dicembre 2016 - Prato 1 di 24
Postgrest: la REST API per i database PostgreSQL 
Lucio Grenzi
l.grenzi@gmail.com
PGDay.IT 2016 – 13 Dicembre 2016 - Prato 2 di 24
Who is this guy?
Delphi developer since 1999
IT Consultant 
Front end web developer
Postgresql addicted
      Nonantolando.blogspot.com
      lucio.grenzi
      lucio grenzi
PGDay.IT 2016 – 13 Dicembre 2016 - Prato 3 di 24
AgendaAgenda
 NoBackend: what and why
 Postgresql: advantages 
 Postgrest features
PGDay.IT 2016 – 13 Dicembre 2016 - Prato 4 di 24
NobackendNobackend
noBackend is an approach to decouple apps from backends, by abstracting 
backend tasks with frontend code. 
This  allows  frontend  developers  to  focus  on  user  experience  and  gives 
backend developers more flexibility on the implementation side.
­ nobackend.org ­
PGDay.IT 2016 – 13 Dicembre 2016 - Prato 5 di 24
Our purposeOur purpose
Create apps / webapps that don't need a backend at all
Writing  business  logic  often  duplicates,  ignores  or  hobbles 
database structure
A single declarative source of truth: the data itself
How?
Using a REST API on top of your database
PGDay.IT 2016 – 13 Dicembre 2016 - Prato 6 di 24
Build a backend in right wayBuild a backend in right way
SSL to rest api always!
Different schema to different port
Implement only what you need
Use webserver to route in the right way
Authentication done by JWT
Row level security feature introduced from Postgresql 9.5
PGDay.IT 2016 – 13 Dicembre 2016 - Prato 7 di 24
Why schemas?Why schemas?
It allows many users to use one database without interfering 
with each other.
It organizes database objects into logical groups to make them 
more manageable.
Third­party applications can be put into separate schemas so 
they do not collide with the names of other objects.
PGDay.IT 2016 – 13 Dicembre 2016 - Prato 8 di 24
Why PostgresqlWhy Postgresql
Versatility
json support
Custom languages (Plv8)
Lots of extensions
MVC logic inside the database
PGDay.IT 2016 – 13 Dicembre 2016 - Prato 9 di 24
MVCMVC
MVC  is  an  architectural  design  pattern  that  encourages 
improved  application  organization  through  a  separation  of 
concerns. It enforces the isolation of business data (Models) 
from  user  interfaces  (Views),  with  a  third  component 
(Controllers)  traditionally  managing  logic,  user­input,  and 
coordination of Models and Views.
­ Developing Backbone.js Applications ­
By Addy Osmani
PGDay.IT 2016 – 13 Dicembre 2016 - Prato 10 di 24
Build an applicationBuild an application
Focus on client related tecnology
Pick a frontend framework
PGDay.IT 2016 – 13 Dicembre 2016 - Prato 11 di 24
PostgrestPostgrest
Cleaner and a more standards compliant API
Quick to get started
Nothing to install
Nothing to configure
Exchange data json format
Postgresql + Postgrest: combination that can give you a way to expose your 
data to other applications or web frontends.
PGDay.IT 2016 – 13 Dicembre 2016 - Prato 12 di 24
Postgrest parameters/optionsPostgrest parameters/options
Usage: postgrest DB_URL (-a|--anonymous ROLE) [-s|--schema NAME]
[-p|--port PORT] [-j|--jwt-secret SECRET] [-o|--pool COUNT]
[-m|--max-rows COUNT]
PostgREST 0.3.2.0 / create a REST API to an existing Postgres database
Available options:
-h,--help Show this help text
DB_URL (REQUIRED) database connection string, e.g.
postgres://user:pass@host:port/db
-a,--anonymous ROLE (REQUIRED) postgres role to use for non-
authenticated requests
-s,--schema NAME schema to use for API routes (default: "public")
-p,--port PORT port number on which to run HTTP
server (default: 3000)
-j,--jwt-secret SECRET secret used to encrypt and decrypt JWT
tokens (default: "secret")
-o,--pool COUNT max connections in database pool (default: 10)
-m,--max-rows COUNT max rows in response (default: "infinity")
PGDay.IT 2016 – 13 Dicembre 2016 - Prato 13 di 24
Postgrest - securityPostgrest - security
PostgREST is designed to keep the database at the center of API security
All authorization happens through database roles and permissions
Use json web sockets to
 authenticate API request
 authenticate  with external services
PGDay.IT 2016 – 13 Dicembre 2016 - Prato 14 di 24
Postgrest – security with no jwtPostgrest – security with no jwt
If 
no JWT is present 
it the role is invalid
it does not contain the role claim
SET LOCAL ROLE anonymous;
PGDay.IT 2016 – 13 Dicembre 2016 - Prato 15 di 24
Postgrest – security with jwtPostgrest – security with jwt
CREATE ROLE authenticator NOINHERIT LOGIN;
CREATE ROLE anonymous;
GRANT anonymous  TO authenticator;
postgrest postgres://pgday@localhost:5432/pgday ­­anonymous anon
PGDay.IT 2016 – 13 Dicembre 2016 - Prato 16 di 24
Postgrest - performancesPostgrest - performances
Web application written in Haskell 
using Warp http server
It delegates as much calculation as possible to the database
Serializing JSON responses directly in SQL
Data validation
Authorization
PGDay.IT 2016 – 13 Dicembre 2016 - Prato 17 di 24
Postgrest - VersioningPostgrest - Versioning
A  long­lived  API  needs  the  freedom  to  exist  in  multiple 
versions
PostgREST does versioning through database schemas
PGDay.IT 2016 – 13 Dicembre 2016 - Prato 18 di 24
API matchesAPI matches
    POST ~ INSERT
    GET ~ SELECT
    PATCH ~ UPDATE
    PUT ~ UPSERT
    DELETE ~ DELETE
    Auth ~ user roles
PGDay.IT 2016 – 13 Dicembre 2016 - Prato 19 di 24
API callsAPI calls
GET /customer?select=name, age, city,nation
POST /customer name, age, city,nation John,40,Boston,USA
PGDay.IT 2016 – 13 Dicembre 2016 - Prato 20 di 24
Try postgrestTry postgrest
Source: https://github.com/begriffs/postgrest/
Docker image                 https://hub.docker.com/r/begriffs/postgrest/
Heroku
Postgrest: http://postgrest.com/
PGDay.IT 2016 – 13 Dicembre 2016 - Prato 21 di 24
Postgrest clientPostgrest client
PostgREST JavaScript client provides  bindings and features 
to be used with PostgREST APIs.
Install with NPM in your project‘s folder.
 $ npm install postgrest­client
 
 var PostgREST = require('postgrest­client')    
 var Api = new PostgREST('https://postgrest.pgday.it')
PGDay.IT 2016 – 13 Dicembre 2016 - Prato 22 di 24
Similar tool to PostgrestSimilar tool to Postgrest
PgREST http://pgre.st/
a JSON document store
PostGraphQL https://github.com/calebmer/postgraphql
a GraphQL schema created over a PostgreSQL schema
PGDay.IT 2016 – 13 Dicembre 2016 - Prato 23 di 24
Questions?Questions?
PGDay.IT 2016 – 13 Dicembre 2016 - Prato 24 di 24

More Related Content

PPTX
A Tour of PostgREST
PPTX
データ分析の目的に応じた人事、分析組織づくり、データ人材の評価
PDF
市場価値で給料が決まるサイボウズの社員だけど、転職ドラフトに参加して給与交渉に挑戦してみました —結果編—
PDF
3分でわかる Azure Managed Diskのしくみ
PDF
【de:code 2020】 Azure Synapse Analytics 技術編 ~ 最新の統合分析プラットフォームによる新しい価値の創出(前編)
PPTX
検索サービス開発が絶対におもしろいと思う理由
PPTX
AlloyDBを触ってみた!(第33回PostgreSQLアンカンファレンス@オンライン 発表資料)
PDF
JSUG 20141127 「Spring Bootを用いたドメイン駆動設計」
A Tour of PostgREST
データ分析の目的に応じた人事、分析組織づくり、データ人材の評価
市場価値で給料が決まるサイボウズの社員だけど、転職ドラフトに参加して給与交渉に挑戦してみました —結果編—
3分でわかる Azure Managed Diskのしくみ
【de:code 2020】 Azure Synapse Analytics 技術編 ~ 最新の統合分析プラットフォームによる新しい価値の創出(前編)
検索サービス開発が絶対におもしろいと思う理由
AlloyDBを触ってみた!(第33回PostgreSQLアンカンファレンス@オンライン 発表資料)
JSUG 20141127 「Spring Bootを用いたドメイン駆動設計」

What's hot (20)

PDF
コンテナ時代にインフラエンジニアは何をするのか
PDF
k8s初心者が gRPC × envoyを導入したら色々苦労した話 #yjbonfire
PDF
初心者向けインターネットの仕組みと8/25の障害についての説明
PDF
20220314 Amazon Linux2022 をさわってみた
PDF
PostgreSQL13でのレプリケーション関連の改善について(第14回PostgreSQLアンカンファレンス@オンライン)
PDF
並列クエリを実行するPostgreSQLのアーキテクチャ
PPTX
FIWARE Big Data Ecosystem : Cygnus and STH Comet
PDF
AWS Black Belt Online Seminar 2018 AWS上の位置情報
PDF
パケットが教えてくれた ルートサーバが 13個の理由
PDF
UnboundとNSDの紹介 BIND9との比較編
PPTX
PostgreSQLのgitレポジトリから見える2021年の開発状況(第30回PostgreSQLアンカンファレンス@オンライン 発表資料)
PDF
PostgreSQLアーキテクチャ入門(INSIGHT OUT 2011)
PPTX
Reserved Instance 及び Savings Plan を感覚的に理解する
PPTX
Cloud Spanner をより便利にする運用支援ツールの紹介
PDF
Apache tinkerpopとグラフデータベースの世界
PDF
FIDO in Windows10
PPTX
Hadoop Compatible File Systems (Azure編) (セミナー「Big Data Developerに贈る第二弾 ‐ Azur...
PDF
[JAWS DAYS 2019] Amazon DocumentDB(with MongoDB Compatibility)入門
PDF
PFNのML/DL基盤を支えるKubernetesにおける自動化 / DevOpsDays Tokyo 2021
PDF
コンテナライフサイクルを守るセキュリティソリューション Aqua Cloud Native Security Platform
コンテナ時代にインフラエンジニアは何をするのか
k8s初心者が gRPC × envoyを導入したら色々苦労した話 #yjbonfire
初心者向けインターネットの仕組みと8/25の障害についての説明
20220314 Amazon Linux2022 をさわってみた
PostgreSQL13でのレプリケーション関連の改善について(第14回PostgreSQLアンカンファレンス@オンライン)
並列クエリを実行するPostgreSQLのアーキテクチャ
FIWARE Big Data Ecosystem : Cygnus and STH Comet
AWS Black Belt Online Seminar 2018 AWS上の位置情報
パケットが教えてくれた ルートサーバが 13個の理由
UnboundとNSDの紹介 BIND9との比較編
PostgreSQLのgitレポジトリから見える2021年の開発状況(第30回PostgreSQLアンカンファレンス@オンライン 発表資料)
PostgreSQLアーキテクチャ入門(INSIGHT OUT 2011)
Reserved Instance 及び Savings Plan を感覚的に理解する
Cloud Spanner をより便利にする運用支援ツールの紹介
Apache tinkerpopとグラフデータベースの世界
FIDO in Windows10
Hadoop Compatible File Systems (Azure編) (セミナー「Big Data Developerに贈る第二弾 ‐ Azur...
[JAWS DAYS 2019] Amazon DocumentDB(with MongoDB Compatibility)入門
PFNのML/DL基盤を支えるKubernetesにおける自動化 / DevOpsDays Tokyo 2021
コンテナライフサイクルを守るセキュリティソリューション Aqua Cloud Native Security Platform
Ad

Viewers also liked (20)

PPTX
PostgREST Design Philosophy
PDF
using Mithril.js + postgREST to build and consume API's
PDF
PgREST: Node.js in the Database
PDF
Django e il Rap Elia Contini
PDF
2007 - 应用系统脆弱性概论
PDF
Vim for Mere Mortals
PDF
The Django Book, Chapter 16: django.contrib
PDF
PythonBrasil[8] closing
PPT
Load testing
PDF
The Django Book Chapter 9 - Django Workshop - Taipei.py
PDF
NoSql Day - Apertura
PPTX
2016 py con2016_lightingtalk_php to python
PDF
Website optimization
PDF
라이트닝 토크 2015 파이콘
KEY
Overview of Testing Talks at Pycon
PDF
User-centered open source
PDF
Django - The Web framework for perfectionists with deadlines
ODP
Rabbitmq & Postgresql
PDF
NoSql Day - Chiusura
PDF
PyClab.__init__(self)
PostgREST Design Philosophy
using Mithril.js + postgREST to build and consume API's
PgREST: Node.js in the Database
Django e il Rap Elia Contini
2007 - 应用系统脆弱性概论
Vim for Mere Mortals
The Django Book, Chapter 16: django.contrib
PythonBrasil[8] closing
Load testing
The Django Book Chapter 9 - Django Workshop - Taipei.py
NoSql Day - Apertura
2016 py con2016_lightingtalk_php to python
Website optimization
라이트닝 토크 2015 파이콘
Overview of Testing Talks at Pycon
User-centered open source
Django - The Web framework for perfectionists with deadlines
Rabbitmq & Postgresql
NoSql Day - Chiusura
PyClab.__init__(self)
Ad

Similar to Postgrest: the REST API for PostgreSQL databases (20)

PDF
Writing infinite scalability web applications with PHP and PostgreSQL
PDF
Choisir entre une API RPC, SOAP, REST, GraphQL? 
Et si le problème était ai...
PDF
Azure HDlnsight에서 R 및 Spark를 이용하여 확장 가능한 머신러닝
PDF
Juraj vysvader - Python developer's CV
PDF
События, шины и интеграция данных в непростом мире микросервисов / Валентин Г...
PDF
Introduction to python
PDF
Design for X: Exploring Product Design with Apache Spark and GraphLab
PDF
Sparklyr: Big Data enabler for R users
PDF
Sparklyr: Big Data enabler for R users - Serena Signorelli, ICTEAM
PDF
Secure Code Review 101
PDF
PLNOG 18 - Piotr Wojciechowski - REST API czyli jak miękko wejść w programowa...
PDF
“Full Stack” Data Science with R for Startups: Production-ready with Open-Sou...
PDF
Useful PostgreSQL Extensions
 
PDF
Demi Ben-Ari - Monitoring Big Data Systems Done "The Simple Way" - Codemotion...
PDF
Monitoring Big Data Systems Done "The Simple Way" - Codemotion Milan 2017 - D...
PDF
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
PDF
PDF
Building Event-Driven (Micro) Services with Apache Kafka
PDF
Vital.AI Creating Intelligent Apps
PDF
BroadStrong Software Room Profile
Writing infinite scalability web applications with PHP and PostgreSQL
Choisir entre une API RPC, SOAP, REST, GraphQL? 
Et si le problème était ai...
Azure HDlnsight에서 R 및 Spark를 이용하여 확장 가능한 머신러닝
Juraj vysvader - Python developer's CV
События, шины и интеграция данных в непростом мире микросервисов / Валентин Г...
Introduction to python
Design for X: Exploring Product Design with Apache Spark and GraphLab
Sparklyr: Big Data enabler for R users
Sparklyr: Big Data enabler for R users - Serena Signorelli, ICTEAM
Secure Code Review 101
PLNOG 18 - Piotr Wojciechowski - REST API czyli jak miękko wejść w programowa...
“Full Stack” Data Science with R for Startups: Production-ready with Open-Sou...
Useful PostgreSQL Extensions
 
Demi Ben-Ari - Monitoring Big Data Systems Done "The Simple Way" - Codemotion...
Monitoring Big Data Systems Done "The Simple Way" - Codemotion Milan 2017 - D...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
Building Event-Driven (Micro) Services with Apache Kafka
Vital.AI Creating Intelligent Apps
BroadStrong Software Room Profile

More from Lucio Grenzi (12)

ODP
How to use Postgresql in order to handle Prometheus metrics storage
ODP
Building serverless application on the Apache Openwhisk platform
ODP
Patroni: PostgreSQL HA in the cloud
PPTX
Full slidescr16
ODP
Use Ionic Framework to develop mobile application
ODP
Jenkins djangovillage
ODP
Geodjango and HTML 5
ODP
PLV8 - The PostgreSQL web side
ODP
Pg tap
PPT
Geodjango
PPT
Yui app-framework
PPT
node.js e Postgresql
How to use Postgresql in order to handle Prometheus metrics storage
Building serverless application on the Apache Openwhisk platform
Patroni: PostgreSQL HA in the cloud
Full slidescr16
Use Ionic Framework to develop mobile application
Jenkins djangovillage
Geodjango and HTML 5
PLV8 - The PostgreSQL web side
Pg tap
Geodjango
Yui app-framework
node.js e Postgresql

Recently uploaded (20)

PPTX
Essential Infomation Tech presentation.pptx
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Design an Analysis of Algorithms I-SECS-1021-03
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
How Creative Agencies Leverage Project Management Software.pdf
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
AI in Product Development-omnex systems
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
medical staffing services at VALiNTRY
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
Odoo POS Development Services by CandidRoot Solutions
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
Transform Your Business with a Software ERP System
Essential Infomation Tech presentation.pptx
Reimagine Home Health with the Power of Agentic AI​
Design an Analysis of Algorithms I-SECS-1021-03
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Wondershare Filmora 15 Crack With Activation Key [2025
How Creative Agencies Leverage Project Management Software.pdf
VVF-Customer-Presentation2025-Ver1.9.pptx
CHAPTER 2 - PM Management and IT Context
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
AI in Product Development-omnex systems
Design an Analysis of Algorithms II-SECS-1021-03
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
2025 Textile ERP Trends: SAP, Odoo & Oracle
medical staffing services at VALiNTRY
PTS Company Brochure 2025 (1).pdf.......
How to Migrate SBCGlobal Email to Yahoo Easily
Odoo POS Development Services by CandidRoot Solutions
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Transform Your Business with a Software ERP System

Postgrest: the REST API for PostgreSQL databases

  • 1. PGDay.IT 2016 – 13 Dicembre 2016 - Prato 1 di 24 Postgrest: la REST API per i database PostgreSQL  Lucio Grenzi l.grenzi@gmail.com
  • 2. PGDay.IT 2016 – 13 Dicembre 2016 - Prato 2 di 24 Who is this guy? Delphi developer since 1999 IT Consultant  Front end web developer Postgresql addicted       Nonantolando.blogspot.com       lucio.grenzi       lucio grenzi
  • 3. PGDay.IT 2016 – 13 Dicembre 2016 - Prato 3 di 24 AgendaAgenda  NoBackend: what and why  Postgresql: advantages   Postgrest features
  • 4. PGDay.IT 2016 – 13 Dicembre 2016 - Prato 4 di 24 NobackendNobackend noBackend is an approach to decouple apps from backends, by abstracting  backend tasks with frontend code.  This  allows  frontend  developers  to  focus  on  user  experience  and  gives  backend developers more flexibility on the implementation side. ­ nobackend.org ­
  • 5. PGDay.IT 2016 – 13 Dicembre 2016 - Prato 5 di 24 Our purposeOur purpose Create apps / webapps that don't need a backend at all Writing  business  logic  often  duplicates,  ignores  or  hobbles  database structure A single declarative source of truth: the data itself How? Using a REST API on top of your database
  • 6. PGDay.IT 2016 – 13 Dicembre 2016 - Prato 6 di 24 Build a backend in right wayBuild a backend in right way SSL to rest api always! Different schema to different port Implement only what you need Use webserver to route in the right way Authentication done by JWT Row level security feature introduced from Postgresql 9.5
  • 7. PGDay.IT 2016 – 13 Dicembre 2016 - Prato 7 di 24 Why schemas?Why schemas? It allows many users to use one database without interfering  with each other. It organizes database objects into logical groups to make them  more manageable. Third­party applications can be put into separate schemas so  they do not collide with the names of other objects.
  • 8. PGDay.IT 2016 – 13 Dicembre 2016 - Prato 8 di 24 Why PostgresqlWhy Postgresql Versatility json support Custom languages (Plv8) Lots of extensions MVC logic inside the database
  • 9. PGDay.IT 2016 – 13 Dicembre 2016 - Prato 9 di 24 MVCMVC MVC  is  an  architectural  design  pattern  that  encourages  improved  application  organization  through  a  separation  of  concerns. It enforces the isolation of business data (Models)  from  user  interfaces  (Views),  with  a  third  component  (Controllers)  traditionally  managing  logic,  user­input,  and  coordination of Models and Views. ­ Developing Backbone.js Applications ­ By Addy Osmani
  • 10. PGDay.IT 2016 – 13 Dicembre 2016 - Prato 10 di 24 Build an applicationBuild an application Focus on client related tecnology Pick a frontend framework
  • 11. PGDay.IT 2016 – 13 Dicembre 2016 - Prato 11 di 24 PostgrestPostgrest Cleaner and a more standards compliant API Quick to get started Nothing to install Nothing to configure Exchange data json format Postgresql + Postgrest: combination that can give you a way to expose your  data to other applications or web frontends.
  • 12. PGDay.IT 2016 – 13 Dicembre 2016 - Prato 12 di 24 Postgrest parameters/optionsPostgrest parameters/options Usage: postgrest DB_URL (-a|--anonymous ROLE) [-s|--schema NAME] [-p|--port PORT] [-j|--jwt-secret SECRET] [-o|--pool COUNT] [-m|--max-rows COUNT] PostgREST 0.3.2.0 / create a REST API to an existing Postgres database Available options: -h,--help Show this help text DB_URL (REQUIRED) database connection string, e.g. postgres://user:pass@host:port/db -a,--anonymous ROLE (REQUIRED) postgres role to use for non- authenticated requests -s,--schema NAME schema to use for API routes (default: "public") -p,--port PORT port number on which to run HTTP server (default: 3000) -j,--jwt-secret SECRET secret used to encrypt and decrypt JWT tokens (default: "secret") -o,--pool COUNT max connections in database pool (default: 10) -m,--max-rows COUNT max rows in response (default: "infinity")
  • 13. PGDay.IT 2016 – 13 Dicembre 2016 - Prato 13 di 24 Postgrest - securityPostgrest - security PostgREST is designed to keep the database at the center of API security All authorization happens through database roles and permissions Use json web sockets to  authenticate API request  authenticate  with external services
  • 14. PGDay.IT 2016 – 13 Dicembre 2016 - Prato 14 di 24 Postgrest – security with no jwtPostgrest – security with no jwt If  no JWT is present  it the role is invalid it does not contain the role claim SET LOCAL ROLE anonymous;
  • 15. PGDay.IT 2016 – 13 Dicembre 2016 - Prato 15 di 24 Postgrest – security with jwtPostgrest – security with jwt CREATE ROLE authenticator NOINHERIT LOGIN; CREATE ROLE anonymous; GRANT anonymous  TO authenticator; postgrest postgres://pgday@localhost:5432/pgday ­­anonymous anon
  • 16. PGDay.IT 2016 – 13 Dicembre 2016 - Prato 16 di 24 Postgrest - performancesPostgrest - performances Web application written in Haskell  using Warp http server It delegates as much calculation as possible to the database Serializing JSON responses directly in SQL Data validation Authorization
  • 17. PGDay.IT 2016 – 13 Dicembre 2016 - Prato 17 di 24 Postgrest - VersioningPostgrest - Versioning A  long­lived  API  needs  the  freedom  to  exist  in  multiple  versions PostgREST does versioning through database schemas
  • 18. PGDay.IT 2016 – 13 Dicembre 2016 - Prato 18 di 24 API matchesAPI matches     POST ~ INSERT     GET ~ SELECT     PATCH ~ UPDATE     PUT ~ UPSERT     DELETE ~ DELETE     Auth ~ user roles
  • 19. PGDay.IT 2016 – 13 Dicembre 2016 - Prato 19 di 24 API callsAPI calls GET /customer?select=name, age, city,nation POST /customer name, age, city,nation John,40,Boston,USA
  • 20. PGDay.IT 2016 – 13 Dicembre 2016 - Prato 20 di 24 Try postgrestTry postgrest Source: https://github.com/begriffs/postgrest/ Docker image                 https://hub.docker.com/r/begriffs/postgrest/ Heroku Postgrest: http://postgrest.com/
  • 21. PGDay.IT 2016 – 13 Dicembre 2016 - Prato 21 di 24 Postgrest clientPostgrest client PostgREST JavaScript client provides  bindings and features  to be used with PostgREST APIs. Install with NPM in your project‘s folder.  $ npm install postgrest­client    var PostgREST = require('postgrest­client')      var Api = new PostgREST('https://postgrest.pgday.it')
  • 22. PGDay.IT 2016 – 13 Dicembre 2016 - Prato 22 di 24 Similar tool to PostgrestSimilar tool to Postgrest PgREST http://pgre.st/ a JSON document store PostGraphQL https://github.com/calebmer/postgraphql a GraphQL schema created over a PostgreSQL schema
  • 23. PGDay.IT 2016 – 13 Dicembre 2016 - Prato 23 di 24 Questions?Questions?
  • 24. PGDay.IT 2016 – 13 Dicembre 2016 - Prato 24 di 24