PostgREST: a webserver and RESTful API for any PostgreSQL database

postgREST

PostgREST serves a full RESTful API from any existing PostgreSQL database. Provides a cleaner, more compatible API

Today we are going to talk about postgREST, which is a standalone web server that transforms a data base PostgreSQL directly in a RESTful API. Structural constraints and database permissions determine API endpoints and operations.

According to its designers, using PostgREST is an alternative to CRUD programming Handbook. Remember that the computer acronym CRUD (Create, Read, Update, Delete) designates the four basic operations for data persistence, in particular the storage of information in a database.

“PostgREST is powerful, stable and transparent. It allows us to start projects very quickly and focus on our data and applications instead of building the ORM layer. In our k8s cluster, we run a few pods per schema that we want to expose and scale up or down based on demand. 

For those who are unaware of PostgreSQL, you should know that this is a data management system known for its reliability and robustness, benefits from over 25 years of open source development by a global developer community. It is one of the most advanced open source database management systems. It is feature-rich, with robust data types, powerful indexing, and a wide range of built-in functions that can be used to simplify the data stack and allow developers to focus on building their app.

PostgREST is narrow in scope, plus it works well with other tools like the Nginx web server. This forces a clear separation of data-centric CRUD operations from other concerns.

postgREST handles authentication (via JSON Web Tokens) and delegates authorization to the role information defined in the database. This ensures that there is only one declarative source of truth for security.

When dealing with the database, the server assumes the identity of the currently authenticated user and during the connection it cannot do anything that the user himself cannot do. Other forms of authentication can be constructed in the JWT primitive.

On the other hand, when it comes to data integrity, PostgREST instead of relying on an Object Relational Mapper (ORM) and a custom imperative encoding, this system imposes declarative constraints directly on your database.

With PostgREST, there is no ORM (object relational mapping) involved, plus the creation of new views is done in SQL, with known performance consequences. A database administrator can now create an API from scratch, without custom programming.

The ORM is a type of computer program that is placed as an interface between an application program and a relational database to simulate an object-oriented database. This program defines mappings between the database schemas and the application program classes.

finally if you are interested in knowing more about it, you can check the details In the following link.

How to install PostgREST on Linux?

Version 10.1.1 was released last November with new additions and some changes. This version can be obtained from github. The link is this.

Similarly, for those interested in being able to install PostgREST, they should know that the current version can be obtained right now with the help of a terminator. Only in it we are going to type:

wget https://github.com/PostgREST/postgrest/releases/download/v10.1.1/postgrest-v10.1.1-linux-static-x64.tar.xz

Now they just have to unzip the package with the following command:

tar Jxf postgrest-v10.1.1-linux-static-x64.tar.xz

While in the special case of those who use a 64-bit version of Ubuntu:

wget https://github.com/PostgREST/postgrest/releases/download/v10.1.1/postgrest-v10.1.1-ubuntu-aarch64.tar.xz
tar Jxf postgrest-v10.1.1-ubuntu-aarch64.tar.xz

And they can run with:

./postgrest --help

Another installation method is with a Docker image that is ready, you can get it by typing:

docker pull postgrest/postgrest

Finally you can get more information about the configuration of it, from the documentation on its website. The link is this.


Be the first to comment

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: AB Internet Networks 2008 SL
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.