tutorial··5 min read·WoWSQL Team

What Is PostgREST? Auto REST APIs for Postgres

What is PostgREST? How it turns Postgres tables into REST endpoints, eq/gt filters, RLS with JWTs, when to use it, and managed options incl. WoWSQL.

PostgREST is an open-source web server that turns a PostgreSQL database into a REST API: every table and view in an exposed schema becomes an endpoint such as GET /todos?done=eq.false, and the database's own permissions and Row Level Security decide what each caller can see. You can run it yourself, or use a managed Postgres platform that runs it for you. Supabase, Neon and WoWSQL all offer one, and on WoWSQL it is the auto-generated REST API at https://<project>.wowsqlconnect.com/rest/v1/.

This guide explains how PostgREST maps tables to URLs, how its filters and security model work, when it beats a hand-written API (and when it doesn't), and how to call it on a managed project. PostgREST, Supabase and Neon facts were checked on their own docs on 24 November 2026.

Key facts

  • What it is: "a standalone web server that turns your PostgreSQL database directly into a RESTful API" (PostgREST docs). MIT-licensed, written in Haskell. The latest release was v16.6, published on 17 November 2026 IST (GitHub releases).
  • How URLs work: one route per table or view (/people), with filters in the query string (?age=gte.18&student=is.true). There are no nested routes; related rows come back through resource embedding.
  • Security model: PostgREST verifies a JWT, switches to the database role named in it (SET LOCAL ROLE), and lets Postgres grants and RLS policies authorise the request.
  • Managed options: Supabase's Data API (https://<project_ref>.supabase.co/rest/v1/), Neon's Data API (described as "fully compatible with PostgREST"), and WoWSQL's REST API (https://<project>.wowsqlconnect.com/rest/v1/).
  • WoWSQL specifics: send the anon key (wowsql_anon_…) in the apikey header and the signed-in user's JWT in Authorization: Bearer so RLS applies. The service key bypasses RLS and belongs on a server only. WoWSQL has no GraphQL API.
  • WoWSQL plans (pricing, USD): Free $0, Pro $25/month, Scale $99/month. REST and MCP APIs are listed on all three. Regions: Mumbai (ap-south-1), US East (us-east-1) and Frankfurt (eu-central-1).

How PostgREST turns tables into endpoints

PostgREST reads your schema at startup (its "schema cache") and exposes every table and view in the configured schema that the current role can access. The PostgREST docs describe the routes as "one-level deep": the people table lives at /people, and there is deliberately no /films/1/director.

The HTTP verb maps to SQL:

HTTP SQL Example
GET SELECT GET /todos?select=id,title&done=eq.false
POST INSERT POST /todos with a JSON body (an array inserts many rows)
PATCH UPDATE PATCH /todos?id=eq.42 with {"done": true}
DELETE DELETE DELETE /todos?id=eq.42
POST /rpc/fn call a function POST /rpc/search_todos with the function's arguments

Which verbs actually work on a route depends "entirely on database permissions". If the role has no INSERT grant, POST fails. Supabase's docs note that each request "resolves... to a single SQL statement", which is why the API layer stays thin.

Three practical consequences:

  • Schema changes become API changes. Add a column and it can be selected right away. When you change tables or foreign keys outside a migration tool, PostgREST needs a schema cache reload; on self-hosted PostgREST that is NOTIFY pgrst, 'reload schema'.
  • Views and functions are your "custom endpoints". A view gives you a reshaped, read-only resource. A Postgres function exposed under /rpc/ gives you a procedure call.
  • There is no ORM. Joins, constraints and defaults live in SQL, and the query planner does the work.

The URL grammar: select, filters, order and pagination

Most PostgREST requests are made of four query-string parts.

Columns with select:

GET /todos?select=id,title,done

Filters as column=operator.value. These are the operators you will use most, from the PostgREST tables and views reference:

Operator SQL Example
eq = ?status=eq.active
neq <> ?status=neq.deleted
gt / gte > / >= ?age=gte.18
lt / lte < / <= ?price=lt.100
like / ilike LIKE / ILIKE ?name=ilike.*john* (* stands for %)
in IN ?role=in.(admin,editor)
is IS ?deleted_at=is.null
fts @@ full-text search ?body=fts.postgres
cs / cd @> / <@ (arrays, ranges, JSON) ?tags=cs.{sql,api}

Put not. in front to negate (?email=not.is.null). Repeat a column to combine conditions on it (?price=gte.10&price=lte.50), and use or=(...) for OR logic.

Order and pagination:

GET /todos?order=created_at.desc&limit=20&offset=40

Related rows with resource embedding. When films has a foreign key to directors, one request returns both:

GET /films?select=title,directors(id,last_name)

Write responses: add Prefer: return=representation to POST, PATCH or DELETE to get the affected rows back as JSON.

How PostgREST security works (and why RLS matters)

PostgREST's docs put it plainly: "All authorization happens in the database." The server only authenticates. The flow on each request is:

  1. PostgREST connects as a low-privilege authenticator role.
  2. If the request has a valid JWT, PostgREST reads its role claim and runs SET LOCAL ROLE <that role> for the transaction. With no JWT, it uses the configured anonymous role.
  3. Postgres grants decide which tables and columns the role can touch, and Row Level Security policies decide which rows.

Claims from the token are available to SQL, for example current_setting('request.jwt.claims', true)::json ->> 'email'. Managed platforms wrap this in a helper: on WoWSQL and Supabase, auth.uid() returns the signed-in user's id, so a policy can say using (auth.uid() = user_id).

The flip side is that a table with no RLS, or a sloppy policy, is exposed to anyone holding the public key. Neon's Data API docs warn that the API "has no permission layer of its own", and the same is true of PostgREST anywhere. Enable RLS on every table you expose and test policies as a real user. Our guide What Is Row Level Security in Postgres? walks through USING vs WITH CHECK with a full example.

PostgREST vs a custom API

PostgREST replaces CRUD controllers, not every line of backend code.

Use PostgREST for Write custom code for
CRUD on tables owned by the signed-in user Calls to third-party APIs with secret keys (payments, email, LLMs)
Admin panels, dashboards, internal tools Multi-step workflows that must call external services
Mobile and web apps whose rules fit in RLS policies Webhooks from Stripe, GitHub and similar services
Read-heavy listing, search and filtering Heavy computation, file processing, scheduled jobs
Reports through views and SQL functions Logic you can't or don't want to express in SQL

Most teams combine the two: PostgREST for data, plus a small number of server functions (for example WoWSQL Edge Functions on Pro and Scale) for the parts that need secrets. If your team is not comfortable with SQL, a hand-written API in a language you know may be easier to maintain than complex policies.

Self-hosted PostgREST vs managed options

Self-hosted PostgREST Supabase Data API Neon Data API WoWSQL REST API
Engine PostgREST (MIT) PostgREST "Fully compatible with PostgREST" PostgREST at /rest/v1
Where the JWT comes from Any issuer you configure (jwt-secret, JWK) Supabase Auth Neon Auth (Managed Better Auth) or a provider such as Auth0, Clerk or Firebase Auth WoWSQL project auth
GraphQL No Yes, a separate GraphQL API Not listed in the Data API docs No
Also included Nothing else; add your own auth and storage Auth, storage, realtime, Edge Functions Branching, serverless Postgres Auth, storage, realtime, Edge Functions (Pro and Scale), hosted MCP server
Entry price Your server cost Free $0 (50,000 MAU, 500 MB database, paused after 1 week of inactivity); Pro from $25 See Neon pricing Free $0 (10,000 MAU, 256 MB database); Pro $25; Scale $99

Sources, checked 24 November 2026: PostgREST docs and authentication reference; Supabase Data REST API, Supabase pricing; Neon Data API overview, get started; WoWSQL Swift SDK docs and pricing.

Where the others are stronger:

  • Supabase has a much larger PostgREST ecosystem, a GraphQL API alongside REST, auto-generated API docs in its dashboard, and a far larger free MAU allowance (50,000 vs WoWSQL's 10,000).
  • Neon suits teams that already use Neon branching or want to bring their own auth provider.
  • Self-hosted PostgREST gives full control of version and config, and it is just one binary in front of any Postgres.

Where WoWSQL fits: a managed PostgREST API with auth, storage, realtime and a hosted MCP server on flat plans, a choice of Mumbai, US East or Frankfurt, and an open-source edition under Apache-2.0 (github.com/WoWSQL/WoWSQL) that you can self-host.

Try PostgREST on WoWSQL in five minutes

Step 1: Create a table with RLS

Create a free project at app.wowsql.com/signup, choose a region, enable auth, and run this in the SQL editor:

create table public.todos (
  id uuid primary key default gen_random_uuid(),
  user_id uuid not null,
  title text not null,
  done boolean not null default false,
  created_at timestamptz not null default now()
);

alter table public.todos enable row level security;

create policy "read own todos"   on public.todos for select using (auth.uid() = user_id);
create policy "insert own todos" on public.todos for insert with check (auth.uid() = user_id);
create policy "update own todos" on public.todos for update using (auth.uid() = user_id) with check (auth.uid() = user_id);
create policy "delete own todos" on public.todos for delete using (auth.uid() = user_id);

Copy the anon key from Settings → API.

Step 2: Sign a user in

Auth endpoints live on the same host. /auth/v1/login and /api/auth/login are equivalent, according to the auth docs:

curl -X POST "https://myproject.wowsqlconnect.com/auth/v1/login" \
  -H "apikey: wowsql_anon_your_key_here" \
  -H "Content-Type: application/json" \
  -d '{"email":"user@example.com","password":"SecurePassword123"}'

The response contains access_token (24 hours by default) and refresh_token.

Step 3: Query as that user

curl "https://myproject.wowsqlconnect.com/rest/v1/todos?select=id,title,done&done=eq.false&order=created_at.desc&limit=10" \
  -H "apikey: wowsql_anon_your_key_here" \
  -H "Authorization: Bearer $ACCESS_TOKEN"

Insert a row and get it back:

curl -X POST "https://myproject.wowsqlconnect.com/rest/v1/todos" \
  -H "apikey: wowsql_anon_your_key_here" \
  -H "Authorization: Bearer $ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Prefer: return=representation" \
  -d '{"user_id":"<the user id from /auth/v1/me>","title":"Read the PostgREST docs"}'

Leave out the Authorization header and the same GET should return an empty array, because auth.uid() is empty and the policy matches nothing. That is RLS doing its job.

Step 4: The same thing from TypeScript

@wowsql/sdk 3.10.0 handles sign-in. For user-scoped queries, call the REST API with the user's token. In 3.10.0, WowSQLClient sends the API key you give it as the bearer token, so its .table() queries run as the anon role. That works for public tables but not for per-user rows.

import { ProjectAuthClient } from '@wowsql/sdk'

const BASE = 'https://myproject.wowsqlconnect.com'
const ANON_KEY = 'wowsql_anon_your_key_here'

const auth = new ProjectAuthClient({ projectUrl: 'myproject', apiKey: ANON_KEY })
const login = await auth.signIn({ email: 'user@example.com', password: 'SecurePassword123' })
const accessToken = login.session?.accessToken

const res = await fetch(`${BASE}/rest/v1/todos?select=id,title,done&done=eq.false`, {
  headers: { apikey: ANON_KEY, Authorization: `Bearer ${accessToken}` },
})
const todos = await res.json() // a plain JSON array of rows

If TOTP two-factor is on for the user, signIn returns requires2fa: true and a pendingToken instead of a session. Finish with verifyTwoFactorLogin, as shown in the TypeScript SDK docs. WoWSQL's docs also list SDKs for Python, Go, Java, PHP, Ruby, Rust, Swift, Flutter/Dart, Kotlin and C#.

Common PostgREST gotchas

  • Unfiltered PATCH or DELETE hits every row the role can reach. PostgREST's docs warn about this explicitly. Always add a filter, and let RLS limit the damage.
  • Aggregates need a view or a function. WoWSQL's TypeScript SDK docs note that /rest/v1 does not run SQL GROUP BY/HAVING from SDK calls; use a database view or an RPC function for real totals.
  • Embedding needs foreign keys. select=title,directors(...) only works if PostgREST can see the relationship. Reload the schema cache after you change keys.
  • The anon key is public, the service key is not. Ship the anon key in apps and keep the service key on servers. With RLS off, the anon key can read the table.
  • Big filters belong in functions. Long in.(...) lists and complex OR trees get hard to read in a URL. A SQL function under /rpc/ is cleaner.

Related guides

FAQ

What is PostgREST in simple terms?

PostgREST is a small open-source server that sits in front of PostgreSQL and turns every exposed table and view into a REST endpoint. GET runs a SELECT, POST an INSERT, PATCH an UPDATE and DELETE a DELETE, with filters in the URL such as ?age=gte.18. Database permissions and Row Level Security decide what each caller can access.

How do PostgREST filters like eq and gt work?

Filters go in the query string as column=operator.value. For example, ?status=eq.active means status = 'active', ?age=gt.18 means age > 18, and ?role=in.(admin,editor) is an IN list. Other common operators are neq, gte, lt, lte, like, ilike (with * as the wildcard) and is for null checks. Put not. in front to negate a filter.

Is it safe to call PostgREST directly from a browser or mobile app?

Yes, if every exposed table has Row Level Security and correct grants. PostgREST verifies the user's JWT and switches to that database role, and Postgres enforces the policies. Without RLS, anyone with the public key can read the table. Never ship a service key that bypasses RLS in client code.

Should I use PostgREST or write my own API?

Use PostgREST for CRUD, listing, filtering and reporting where your rules fit in SQL grants and RLS policies. Write custom code, such as an edge or server function, for third-party API calls with secrets, webhooks, multi-step workflows and heavy processing. Most production apps use both.

Does Supabase use PostgREST?

Yes. Supabase's Data REST API is built on PostgREST and served at https://.supabase.co/rest/v1/. Supabase also offers a separate GraphQL API. Neon's Data API is PostgREST-compatible, and WoWSQL's auto-generated REST API at /rest/v1 is PostgREST too.

Is there a managed PostgREST so I don't have to host it?

Yes. Supabase, Neon and WoWSQL all run a PostgREST-style API for you. On WoWSQL it is https://.wowsqlconnect.com/rest/v1/, with project auth, storage and realtime on the Free ($0), Pro ($25/month) and Scale ($99/month) plans, in Mumbai, US East or Frankfurt.

Does WoWSQL have a GraphQL API?

No. WoWSQL provides the PostgREST REST API, realtime over WebSockets, SDKs and a hosted MCP server, but no GraphQL API. If you need GraphQL on Postgres, Supabase offers one.

Create a free WoWSQL project · Pricing · Docs