Skip to content

PostgREST

PostgREST turns a PostgreSQL schema into a REST API with no code. The first publishing design used it: Trino copied a query result into serving.staging_api.<name> and PostgREST served it, protected by an HS256 token and the role api_reader.

That path is retired. New published APIs are views served live by the platform API (Views and APIs). PostgREST and the serving catalog are still installed and untouched, shown on the status page as “legacy”, and are candidates for removal together.

Binary /usr/local/bin/postgrest (step 03, checksum checked)
Config /etc/lake/postgrest/postgrest.conf, jwt.secret
Service postgrest
Port 3000 (127.0.0.1)
Database serving, schema api; anonymous role web_anon
Terminal window
systemctl is-active postgrest
curl -s http://127.0.0.1:3000/ # the OpenAPI document of the schema
curl -s http://127.0.0.1:3000/demo_t # the demo table made by step 08

Only for the demo chain: Trino writes a table into serving.api, then PostgREST must reload its table list:

Terminal window
trino --execute "CREATE TABLE serving.api.demo2 AS SELECT * FROM lake.demo.t"
sudo systemctl kill -s SIGUSR1 postgrest # reload the schema cache
curl -s http://127.0.0.1:3000/demo2

web_anon has no access to published data; reading it requires a token signed with jwt.secret.

Symptom Likely cause
A new table is not served The schema cache is old: send SIGUSR1 as above
Every token is rejected jwt.secret must have no trailing newline
It cannot connect The authenticator password in postgrest.conf differs from PostgreSQL: re-run step 03