Note

This page is a work in progress.

URL Grammar

Custom Queries

The PostgREST URL grammar limits the kinds of queries clients can perform. It prevents arbitrary, potentially poorly constructed and slow client queries. It’s good for quality of service, but means database administrators must create custom views and stored procedures to provide richer endpoints. The most common causes for custom endpoints are

  • Table unions

  • More complicated joins than those provided by Resource Embedding.

  • Geo-spatial queries that require an argument, like “points near (lat,lon)”

Unicode support

PostgREST supports unicode in schemas, tables, columns and values. To access a table with unicode name, use percent encoding.

To request this:

GET /موارد HTTP/1.1

Do this:

GET /%D9%85%D9%88%D8%A7%D8%B1%D8%AF HTTP/1.1

Table / Columns with spaces

You can request table/columns with spaces in them by percent encoding the spaces with %20:

GET /Order%20Items?Unit%20Price=lt.200 HTTP/1.1

Reserved characters

If filters include PostgREST reserved characters(,, ., :, ()) you’ll have to surround them in percent encoded double quotes %22 for correct processing.

Here Hebdon,John and Williams,Mary are values.

GET /employees?name=in.(%22Hebdon,John%22,%22Williams,Mary%22) HTTP/1.1

Here information.cpe is a column name.

GET /vulnerabilities?%22information.cpe%22=like.*MS* HTTP/1.1

If the value filtered by the in operator has a double quote ("), you can escape it using a backslash "\"". A backslash itself can be used with a double backslash "\\".

Here Quote:" and Backslash:\ are percent-encoded values. Note that %5C is the percent-encoded backslash.

GET /marks?name=in.(%22Quote:%5C%22%22,%22Backslash:%5C%5C%22) HTTP/1.1

Note

Some HTTP libraries might encode URLs automatically(e.g. axios). In these cases you should use double quotes "" directly instead of %22.