No description
  • Haskell 67.5%
  • PLpgSQL 21.5%
  • Python 6.5%
  • Nix 4.3%
  • Shell 0.2%
Find a file
Taimoor Zaeem 8faf9c0519 test: resolve pytest warning when running io tests
When running `postgrest-test-io`, pytest raises a `InsecureKeyLengthWarning`
for a test. To clear that warning, this commit increases the key length to
more than 32 characters.

Signed-off-by: Taimoor Zaeem <taimoorzaeem@gmail.com>
2026-07-17 17:42:51 +00:00
.github chore: run doctests in parallel 2026-07-14 06:55:32 +00:00
docs add: use SO_REUSEPORT on platform supporting it 2026-07-15 11:51:21 -05:00
nix chore: move executable code to src/ 2026-07-14 06:58:15 +00:00
src add: use SO_REUSEPORT on platform supporting it 2026-07-15 11:51:21 -05:00
static chore: update sponsor 2026-03-02 17:36:04 -05:00
test test: resolve pytest warning when running io tests 2026-07-17 17:42:51 +00:00
.editorconfig chore: add .editorconfig file 2025-03-28 09:22:34 +00:00
.gitattributes Use union merge strategy on changelog (#859) 2017-04-08 10:36:02 -05:00
.gitignore chore: run doctests in parallel 2026-07-14 06:55:32 +00:00
.readthedocs.yaml chore(deps): fix docs deps 2026-04-27 08:29:41 +00:00
.stylish-haskell.yaml Update stylish haskell config; apply all; add CI config (#1299) 2019-05-23 10:44:34 -05:00
BACKERS.md chore: update sponsors 2026-03-03 22:02:18 -05:00
cabal.project chore: run doctests in parallel 2026-07-14 06:55:32 +00:00
cabal.project.freeze amend: update cabal index so cabal build succeeds 2026-07-11 13:24:09 -05:00
CHANGELOG.md add: use SO_REUSEPORT on platform supporting it 2026-07-15 11:51:21 -05:00
CODE_OF_CONDUCT.md Add Contributor Covenant Code of Conduct v2 2021-04-06 22:22:13 -05:00
CONTRIBUTING.md chore: mentions docs on CONTRIBUTING 2026-06-30 10:06:45 -05:00
default.nix chore(deps): update hackage freeze, stackage snapshot and nixpkgs pin 2026-07-05 12:50:14 +00:00
docker-hub-readme.md chore: add changelog for static aarch64 builds and remove left-overs 2026-04-20 19:29:26 +00:00
flake.lock chore(deps): update hackage freeze, stackage snapshot and nixpkgs pin 2026-07-05 12:50:14 +00:00
flake.nix chore(deps): update nixpkgs to latest nixpkgs-unstable 2026-04-19 13:16:55 +00:00
LICENSE chore: update license 2026-03-10 16:41:42 +00:00
postgrest.cabal chore: build haskell source modules in parallel 2026-07-16 13:34:59 +05:00
README.md chore: update sponsors 2026-03-03 22:02:18 -05:00
Setup.hs add comment to Setup.hs 2021-04-12 20:31:32 +02:00
shell.nix nix: remove unused tools from dev shell 2026-04-28 12:56:53 +00:00
stack.yaml amend: use warp 3.4.14 for 3522917 2026-07-11 13:12:03 -05:00
stack.yaml.lock amend: use warp 3.4.14 for 3522917 2026-07-11 13:12:03 -05:00

Logo

Donate Docs Docker Stars Build Status Coverage Status Hackage docs

PostgREST serves a fully RESTful API from any existing PostgreSQL database. It provides a cleaner, more standards-compliant, faster API than you are likely to write from scratch.

Sponsors

Big thanks to our sponsors! You can join them by supporting PostgREST on Patreon.

Usage

  1. See the docs for how to install PostgREST on your platform. You can also use Docker.

  2. Invoke for help:

    postgrest --help
    

Documentation

Latest documentation is at postgrest.org. You can contribute to the docs in PostgREST/postgrest/docs.

Performance

TLDR; subsecond response times for up to 2000 requests/sec on Heroku free tier. If you're used to servers written in interpreted languages, prepare to be pleasantly surprised by PostgREST performance.

Three factors contribute to the speed. First the server is written in Haskell using the Warp HTTP server (aka a compiled language with lightweight threads). Next it delegates as much calculation as possible to the database including

  • Serializing JSON responses directly in SQL
  • Data validation
  • Authorization
  • Combined row counting and retrieval
  • Data post in single command (returning *)

Finally it uses the database efficiently with the Hasql library by

  • Keeping a pool of db connections
  • Using the PostgreSQL binary protocol
  • Being stateless to allow horizontal scaling

Security

PostgREST handles authentication (via JSON Web Tokens) and delegates authorization to the role information defined in the database. This ensures there is a single declarative source of truth for security. When dealing with the database the server assumes the identity of the currently authenticated user, and for the duration of the connection cannot do anything the user themselves couldn't. Other forms of authentication can be built on top of the JWT primitive. See the docs for more information.

Versioning

A robust long-lived API needs the freedom to exist in multiple versions. PostgREST does versioning through database schemas. This allows you to expose tables and views without making the app brittle. Underlying tables can be superseded and hidden behind public facing views.

Self-documentation

PostgREST uses the OpenAPI standard to generate up-to-date documentation for APIs. You can use a tool like Swagger-UI to render interactive documentation for demo requests against the live API server.

This project uses HTTP to communicate other metadata as well. For instance the number of rows returned by an endpoint is reported by - and limited with - range headers. More about that.

Data Integrity

Rather than relying on an Object Relational Mapper and custom imperative coding, this system requires you to put declarative constraints directly into your database. Hence no application can corrupt your data (including your API server).

The PostgREST exposes HTTP interface with safeguards to prevent surprises, such as enforcing idempotent PUT requests.

See examples of PostgreSQL constraints and the API guide.

Supporting development

You can help PostgREST ongoing maintenance and development by making a regular donation through Patreon https://www.patreon.com/postgrest

Every donation will be spent on making PostgREST better for the whole community.

Contributing

Contributions are always welcome and appreciated. Please see the Contributing guidelines.

Thanks

The PostgREST organization is grateful to:

  • The project sponsors and backers who support PostgREST's development.
  • The project contributors who have improved PostgREST immensely with their code and good judgement. See more details in the changelog.

The cool logo came from Mikey Casalaina.