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
Ad

Recommended

A Tour of PostgREST
A Tour of PostgREST
begriffs
 
MongoDB at Scale
MongoDB at Scale
MongoDB
 
Improve PostgreSQL replication with Oracle GoldenGate
Improve PostgreSQL replication with Oracle GoldenGate
Bobby Curtis
 
PostgreSQL WAL for DBAs
PostgreSQL WAL for DBAs
PGConf APAC
 
Social Network Analysis: Applications & Challenges
Social Network Analysis: Applications & Challenges
IIIT Hyderabad
 
Apache Spark Architecture | Apache Spark Architecture Explained | Apache Spar...
Apache Spark Architecture | Apache Spark Architecture Explained | Apache Spar...
Simplilearn
 
Apache Lucene/Solr Document Classification
Apache Lucene/Solr Document Classification
Sease
 
CouchDB Map/Reduce
CouchDB Map/Reduce
Oliver Kurowski
 
Yurii Pashchenko: Unlocking the potential of Segment Anything Model (UA)
Yurii Pashchenko: Unlocking the potential of Segment Anything Model (UA)
Lviv Startup Club
 
Graph Data Science DEMO for fraud analysis
Graph Data Science DEMO for fraud analysis
Neo4j
 
Streaming with Oracle Data Integration
Streaming with Oracle Data Integration
Michael Rainey
 
Cassandra Data Modelling
Cassandra Data Modelling
Knoldus Inc.
 
Intro to Neo4j presentation
Intro to Neo4j presentation
jexp
 
Neo4j in Depth
Neo4j in Depth
Max De Marzi
 
PostgreSQL Extensions: A deeper look
PostgreSQL Extensions: A deeper look
Jignesh Shah
 
Using neo4j for enterprise metadata requirements
Using neo4j for enterprise metadata requirements
Neo4j
 
Cloudera - The Modern Platform for Analytics
Cloudera - The Modern Platform for Analytics
Cloudera, Inc.
 
Managing the Complete Machine Learning Lifecycle with MLflow
Managing the Complete Machine Learning Lifecycle with MLflow
Databricks
 
Predictive Analytics with Airflow and PySpark
Predictive Analytics with Airflow and PySpark
Russell Jurney
 
Apache Spark overview
Apache Spark overview
DataArt
 
Elena Macro Processor
Elena Macro Processor
Arun C S
 
Processing Large Datasets for ADAS Applications using Apache Spark
Processing Large Datasets for ADAS Applications using Apache Spark
Databricks
 
PySpark Best Practices
PySpark Best Practices
Cloudera, Inc.
 
NeRF: Representing Scenes as Neural Radiance Fields for View Synthesis
NeRF: Representing Scenes as Neural Radiance Fields for View Synthesis
taeseon ryu
 
Graph database Use Cases
Graph database Use Cases
Max De Marzi
 
Visualizing a Database Structure with SchemaSpy
Visualizing a Database Structure with SchemaSpy
Guo Albert
 
Monitoring Oracle Database Instances with Zabbix
Monitoring Oracle Database Instances with Zabbix
Gerger
 
Neo4j Fundamentals
Neo4j Fundamentals
Max De Marzi
 
PostgREST Design Philosophy
PostgREST Design Philosophy
begriffs
 
using Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API's
Antônio Roberto Silva
 

More Related Content

What's hot (20)

Yurii Pashchenko: Unlocking the potential of Segment Anything Model (UA)
Yurii Pashchenko: Unlocking the potential of Segment Anything Model (UA)
Lviv Startup Club
 
Graph Data Science DEMO for fraud analysis
Graph Data Science DEMO for fraud analysis
Neo4j
 
Streaming with Oracle Data Integration
Streaming with Oracle Data Integration
Michael Rainey
 
Cassandra Data Modelling
Cassandra Data Modelling
Knoldus Inc.
 
Intro to Neo4j presentation
Intro to Neo4j presentation
jexp
 
Neo4j in Depth
Neo4j in Depth
Max De Marzi
 
PostgreSQL Extensions: A deeper look
PostgreSQL Extensions: A deeper look
Jignesh Shah
 
Using neo4j for enterprise metadata requirements
Using neo4j for enterprise metadata requirements
Neo4j
 
Cloudera - The Modern Platform for Analytics
Cloudera - The Modern Platform for Analytics
Cloudera, Inc.
 
Managing the Complete Machine Learning Lifecycle with MLflow
Managing the Complete Machine Learning Lifecycle with MLflow
Databricks
 
Predictive Analytics with Airflow and PySpark
Predictive Analytics with Airflow and PySpark
Russell Jurney
 
Apache Spark overview
Apache Spark overview
DataArt
 
Elena Macro Processor
Elena Macro Processor
Arun C S
 
Processing Large Datasets for ADAS Applications using Apache Spark
Processing Large Datasets for ADAS Applications using Apache Spark
Databricks
 
PySpark Best Practices
PySpark Best Practices
Cloudera, Inc.
 
NeRF: Representing Scenes as Neural Radiance Fields for View Synthesis
NeRF: Representing Scenes as Neural Radiance Fields for View Synthesis
taeseon ryu
 
Graph database Use Cases
Graph database Use Cases
Max De Marzi
 
Visualizing a Database Structure with SchemaSpy
Visualizing a Database Structure with SchemaSpy
Guo Albert
 
Monitoring Oracle Database Instances with Zabbix
Monitoring Oracle Database Instances with Zabbix
Gerger
 
Neo4j Fundamentals
Neo4j Fundamentals
Max De Marzi
 
Yurii Pashchenko: Unlocking the potential of Segment Anything Model (UA)
Yurii Pashchenko: Unlocking the potential of Segment Anything Model (UA)
Lviv Startup Club
 
Graph Data Science DEMO for fraud analysis
Graph Data Science DEMO for fraud analysis
Neo4j
 
Streaming with Oracle Data Integration
Streaming with Oracle Data Integration
Michael Rainey
 
Cassandra Data Modelling
Cassandra Data Modelling
Knoldus Inc.
 
Intro to Neo4j presentation
Intro to Neo4j presentation
jexp
 
PostgreSQL Extensions: A deeper look
PostgreSQL Extensions: A deeper look
Jignesh Shah
 
Using neo4j for enterprise metadata requirements
Using neo4j for enterprise metadata requirements
Neo4j
 
Cloudera - The Modern Platform for Analytics
Cloudera - The Modern Platform for Analytics
Cloudera, Inc.
 
Managing the Complete Machine Learning Lifecycle with MLflow
Managing the Complete Machine Learning Lifecycle with MLflow
Databricks
 
Predictive Analytics with Airflow and PySpark
Predictive Analytics with Airflow and PySpark
Russell Jurney
 
Apache Spark overview
Apache Spark overview
DataArt
 
Elena Macro Processor
Elena Macro Processor
Arun C S
 
Processing Large Datasets for ADAS Applications using Apache Spark
Processing Large Datasets for ADAS Applications using Apache Spark
Databricks
 
PySpark Best Practices
PySpark Best Practices
Cloudera, Inc.
 
NeRF: Representing Scenes as Neural Radiance Fields for View Synthesis
NeRF: Representing Scenes as Neural Radiance Fields for View Synthesis
taeseon ryu
 
Graph database Use Cases
Graph database Use Cases
Max De Marzi
 
Visualizing a Database Structure with SchemaSpy
Visualizing a Database Structure with SchemaSpy
Guo Albert
 
Monitoring Oracle Database Instances with Zabbix
Monitoring Oracle Database Instances with Zabbix
Gerger
 
Neo4j Fundamentals
Neo4j Fundamentals
Max De Marzi
 

Viewers also liked (20)

PostgREST Design Philosophy
PostgREST Design Philosophy
begriffs
 
using Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API's
Antônio Roberto Silva
 
PgREST: Node.js in the Database
PgREST: Node.js in the Database
Audrey Tang
 
Django e il Rap Elia Contini
Django e il Rap Elia Contini
WEBdeBS
 
2007 - 应用系统脆弱性概论
2007 - 应用系统脆弱性概论
Na Lee
 
Vim for Mere Mortals
Vim for Mere Mortals
Clayton Parker
 
The Django Book, Chapter 16: django.contrib
The Django Book, Chapter 16: django.contrib
Tzu-ping Chung
 
PythonBrasil[8] closing
PythonBrasil[8] closing
Tatiana Al-Chueyr
 
Load testing
Load testing
Mindfire Solutions
 
The Django Book Chapter 9 - Django Workshop - Taipei.py
The Django Book Chapter 9 - Django Workshop - Taipei.py
Tzu-ping Chung
 
NoSql Day - Apertura
NoSql Day - Apertura
WEBdeBS
 
2016 py con2016_lightingtalk_php to python
2016 py con2016_lightingtalk_php to python
Jiho Lee
 
Website optimization
Website optimization
Mindfire Solutions
 
라이트닝 토크 2015 파이콘
라이트닝 토크 2015 파이콘
Jiho Lee
 
Overview of Testing Talks at Pycon
Overview of Testing Talks at Pycon
Jacqueline Kazil
 
User-centered open source
User-centered open source
Jacqueline Kazil
 
Django - The Web framework for perfectionists with deadlines
Django - The Web framework for perfectionists with deadlines
Markus Zapke-Gründemann
 
Rabbitmq & Postgresql
Rabbitmq & Postgresql
Lucio Grenzi
 
NoSql Day - Chiusura
NoSql Day - Chiusura
WEBdeBS
 
PyClab.__init__(self)
PyClab.__init__(self)
Tzu-ping Chung
 
PostgREST Design Philosophy
PostgREST Design Philosophy
begriffs
 
using Mithril.js + postgREST to build and consume API's
using Mithril.js + postgREST to build and consume API's
Antônio Roberto Silva
 
PgREST: Node.js in the Database
PgREST: Node.js in the Database
Audrey Tang
 
Django e il Rap Elia Contini
Django e il Rap Elia Contini
WEBdeBS
 
2007 - 应用系统脆弱性概论
2007 - 应用系统脆弱性概论
Na Lee
 
The Django Book, Chapter 16: django.contrib
The Django Book, Chapter 16: django.contrib
Tzu-ping Chung
 
The Django Book Chapter 9 - Django Workshop - Taipei.py
The Django Book Chapter 9 - Django Workshop - Taipei.py
Tzu-ping Chung
 
NoSql Day - Apertura
NoSql Day - Apertura
WEBdeBS
 
2016 py con2016_lightingtalk_php to python
2016 py con2016_lightingtalk_php to python
Jiho Lee
 
라이트닝 토크 2015 파이콘
라이트닝 토크 2015 파이콘
Jiho Lee
 
Overview of Testing Talks at Pycon
Overview of Testing Talks at Pycon
Jacqueline Kazil
 
Django - The Web framework for perfectionists with deadlines
Django - The Web framework for perfectionists with deadlines
Markus Zapke-Gründemann
 
Rabbitmq & Postgresql
Rabbitmq & Postgresql
Lucio Grenzi
 
NoSql Day - Chiusura
NoSql Day - Chiusura
WEBdeBS
 
Ad

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

[BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgR...
[BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgR...
François-Guillaume Ribreau
 
Choisir entre une API RPC, SOAP, REST, GraphQL? 
Et si le problème était ai...
Choisir entre une API RPC, SOAP, REST, GraphQL? 
Et si le problème était ai...
François-Guillaume Ribreau
 
Writing infinite scalability web applications with PHP and PostgreSQL
Writing infinite scalability web applications with PHP and PostgreSQL
Gabriele Bartolini
 
Patroni: PostgreSQL HA in the cloud
Patroni: PostgreSQL HA in the cloud
Lucio Grenzi
 
How to use Postgresql in order to handle Prometheus metrics storage
How to use Postgresql in order to handle Prometheus metrics storage
Lucio Grenzi
 
PostgreSQL 10; Long Awaited Enterprise Solutions
PostgreSQL 10; Long Awaited Enterprise Solutions
Julyanto SUTANDANG
 
Trivadis TechEvent 2017 PostgreSQL für die (Orakel) DBA by Ludovico Caldara
Trivadis TechEvent 2017 PostgreSQL für die (Orakel) DBA by Ludovico Caldara
Trivadis
 
Postgresql
Postgresql
NexThoughts Technologies
 
Oracle to Postgres Migration - part 2
Oracle to Postgres Migration - part 2
PgTraining
 
PostgreSQL Rocks Indonesia
PostgreSQL Rocks Indonesia
PGConf APAC
 
SFScon14: Schrödinger’s elephant: why PostgreSQL can solve all your database ...
SFScon14: Schrödinger’s elephant: why PostgreSQL can solve all your database ...
South Tyrol Free Software Conference
 
Getting started with postgresql
Getting started with postgresql
botsplash.com
 
20240518 - VixulCon 2024 - The Rise of PostgreSQL_ Historic Trends and Modern...
20240518 - VixulCon 2024 - The Rise of PostgreSQL_ Historic Trends and Modern...
Umair Shahid
 
Module 5 Web Programing Setting Up Postgres.pptx
Module 5 Web Programing Setting Up Postgres.pptx
earningmoney9595
 
Bn 1016 demo postgre sql-online-training
Bn 1016 demo postgre sql-online-training
conline training
 
PostgreSQL : Introduction
PostgreSQL : Introduction
Open Source School
 
Don't panic! - Postgres introduction
Don't panic! - Postgres introduction
Federico Campoli
 
An evening with Postgresql
An evening with Postgresql
Joshua Drake
 
PostgreSQL Prologue
PostgreSQL Prologue
Md. Golam Hossain
 
9.6_Course Material-Postgresql_002.pdf
9.6_Course Material-Postgresql_002.pdf
sreedb2
 
[BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgR...
[BreizhCamp, format 15min] Une api rest et GraphQL sans code grâce à PostgR...
François-Guillaume Ribreau
 
Choisir entre une API RPC, SOAP, REST, GraphQL? 
Et si le problème était ai...
Choisir entre une API RPC, SOAP, REST, GraphQL? 
Et si le problème était ai...
François-Guillaume Ribreau
 
Writing infinite scalability web applications with PHP and PostgreSQL
Writing infinite scalability web applications with PHP and PostgreSQL
Gabriele Bartolini
 
Patroni: PostgreSQL HA in the cloud
Patroni: PostgreSQL HA in the cloud
Lucio Grenzi
 
How to use Postgresql in order to handle Prometheus metrics storage
How to use Postgresql in order to handle Prometheus metrics storage
Lucio Grenzi
 
PostgreSQL 10; Long Awaited Enterprise Solutions
PostgreSQL 10; Long Awaited Enterprise Solutions
Julyanto SUTANDANG
 
Trivadis TechEvent 2017 PostgreSQL für die (Orakel) DBA by Ludovico Caldara
Trivadis TechEvent 2017 PostgreSQL für die (Orakel) DBA by Ludovico Caldara
Trivadis
 
Oracle to Postgres Migration - part 2
Oracle to Postgres Migration - part 2
PgTraining
 
PostgreSQL Rocks Indonesia
PostgreSQL Rocks Indonesia
PGConf APAC
 
SFScon14: Schrödinger’s elephant: why PostgreSQL can solve all your database ...
SFScon14: Schrödinger’s elephant: why PostgreSQL can solve all your database ...
South Tyrol Free Software Conference
 
Getting started with postgresql
Getting started with postgresql
botsplash.com
 
20240518 - VixulCon 2024 - The Rise of PostgreSQL_ Historic Trends and Modern...
20240518 - VixulCon 2024 - The Rise of PostgreSQL_ Historic Trends and Modern...
Umair Shahid
 
Module 5 Web Programing Setting Up Postgres.pptx
Module 5 Web Programing Setting Up Postgres.pptx
earningmoney9595
 
Bn 1016 demo postgre sql-online-training
Bn 1016 demo postgre sql-online-training
conline training
 
Don't panic! - Postgres introduction
Don't panic! - Postgres introduction
Federico Campoli
 
An evening with Postgresql
An evening with Postgresql
Joshua Drake
 
9.6_Course Material-Postgresql_002.pdf
9.6_Course Material-Postgresql_002.pdf
sreedb2
 
Ad

More from Lucio Grenzi (10)

Building serverless application on the Apache Openwhisk platform
Building serverless application on the Apache Openwhisk platform
Lucio Grenzi
 
Full slidescr16
Full slidescr16
Lucio Grenzi
 
Use Ionic Framework to develop mobile application
Use Ionic Framework to develop mobile application
Lucio Grenzi
 
Jenkins djangovillage
Jenkins djangovillage
Lucio Grenzi
 
Geodjango and HTML 5
Geodjango and HTML 5
Lucio Grenzi
 
PLV8 - The PostgreSQL web side
PLV8 - The PostgreSQL web side
Lucio Grenzi
 
Pg tap
Pg tap
Lucio Grenzi
 
Geodjango
Geodjango
Lucio Grenzi
 
Yui app-framework
Yui app-framework
Lucio Grenzi
 
node.js e Postgresql
node.js e Postgresql
Lucio Grenzi
 
Building serverless application on the Apache Openwhisk platform
Building serverless application on the Apache Openwhisk platform
Lucio Grenzi
 
Use Ionic Framework to develop mobile application
Use Ionic Framework to develop mobile application
Lucio Grenzi
 
Jenkins djangovillage
Jenkins djangovillage
Lucio Grenzi
 
Geodjango and HTML 5
Geodjango and HTML 5
Lucio Grenzi
 
PLV8 - The PostgreSQL web side
PLV8 - The PostgreSQL web side
Lucio Grenzi
 
node.js e Postgresql
node.js e Postgresql
Lucio Grenzi
 

Recently uploaded (20)

On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
Hassan Abid
 
Complete WordPress Programming Guidance Book
Complete WordPress Programming Guidance Book
Shabista Imam
 
Simplify Insurance Regulations with Compliance Management Software
Simplify Insurance Regulations with Compliance Management Software
Insurance Tech Services
 
arctitecture application system design os dsa
arctitecture application system design os dsa
za241967
 
Y - Recursion The Hard Way GopherCon EU 2025
Y - Recursion The Hard Way GopherCon EU 2025
Eleanor McHugh
 
HYBRIDIZATION OF ALKANES AND ALKENES ...
HYBRIDIZATION OF ALKANES AND ALKENES ...
karishmaduhijod1
 
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
IFI Techsolutions
 
Building Geospatial Data Warehouse for GIS by GIS with FME
Building Geospatial Data Warehouse for GIS by GIS with FME
Safe Software
 
Top Time Tracking Solutions for Accountants
Top Time Tracking Solutions for Accountants
oliviareed320
 
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
Why Every Growing Business Needs a Staff Augmentation Company IN USA.pdf
Why Every Growing Business Needs a Staff Augmentation Company IN USA.pdf
mary rojas
 
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
Automated Testing and Safety Analysis of Deep Neural Networks
Automated Testing and Safety Analysis of Deep Neural Networks
Lionel Briand
 
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
Download Adobe Illustrator Crack free for Windows 2025?
Download Adobe Illustrator Crack free for Windows 2025?
grete1122g
 
Streamlining CI/CD with FME Flow: A Practical Guide
Streamlining CI/CD with FME Flow: A Practical Guide
Safe Software
 
Simplify Task, Team, and Project Management with Orangescrum Work
Simplify Task, Team, and Project Management with Orangescrum Work
Orangescrum
 
IDM Crack with Internet Download Manager 6.42 Build 41 [Latest 2025]
IDM Crack with Internet Download Manager 6.42 Build 41 [Latest 2025]
pcprocore
 
ERP Systems in the UAE: Driving Business Transformation with Smart Solutions
ERP Systems in the UAE: Driving Business Transformation with Smart Solutions
dheeodoo
 
Best Practice for LLM Serving in the Cloud
Best Practice for LLM Serving in the Cloud
Alluxio, Inc.
 
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
On-Device AI: Is It Time to Go All-In, or Do We Still Need the Cloud?
Hassan Abid
 
Complete WordPress Programming Guidance Book
Complete WordPress Programming Guidance Book
Shabista Imam
 
Simplify Insurance Regulations with Compliance Management Software
Simplify Insurance Regulations with Compliance Management Software
Insurance Tech Services
 
arctitecture application system design os dsa
arctitecture application system design os dsa
za241967
 
Y - Recursion The Hard Way GopherCon EU 2025
Y - Recursion The Hard Way GopherCon EU 2025
Eleanor McHugh
 
HYBRIDIZATION OF ALKANES AND ALKENES ...
HYBRIDIZATION OF ALKANES AND ALKENES ...
karishmaduhijod1
 
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
Enable Your Cloud Journey With Microsoft Trusted Partner | IFI Tech
IFI Techsolutions
 
Building Geospatial Data Warehouse for GIS by GIS with FME
Building Geospatial Data Warehouse for GIS by GIS with FME
Safe Software
 
Top Time Tracking Solutions for Accountants
Top Time Tracking Solutions for Accountants
oliviareed320
 
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
Why Every Growing Business Needs a Staff Augmentation Company IN USA.pdf
Why Every Growing Business Needs a Staff Augmentation Company IN USA.pdf
mary rojas
 
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
Automated Testing and Safety Analysis of Deep Neural Networks
Automated Testing and Safety Analysis of Deep Neural Networks
Lionel Briand
 
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
CodeCleaner: Mitigating Data Contamination for LLM Benchmarking
arabelatso
 
Download Adobe Illustrator Crack free for Windows 2025?
Download Adobe Illustrator Crack free for Windows 2025?
grete1122g
 
Streamlining CI/CD with FME Flow: A Practical Guide
Streamlining CI/CD with FME Flow: A Practical Guide
Safe Software
 
Simplify Task, Team, and Project Management with Orangescrum Work
Simplify Task, Team, and Project Management with Orangescrum Work
Orangescrum
 
IDM Crack with Internet Download Manager 6.42 Build 41 [Latest 2025]
IDM Crack with Internet Download Manager 6.42 Build 41 [Latest 2025]
pcprocore
 
ERP Systems in the UAE: Driving Business Transformation with Smart Solutions
ERP Systems in the UAE: Driving Business Transformation with Smart Solutions
dheeodoo
 
Best Practice for LLM Serving in the Cloud
Best Practice for LLM Serving in the Cloud
Alluxio, Inc.
 

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 [email protected]
  • 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