Skip to content

REST API

pgvis exposes a PostgREST-compatible REST API. If you’ve used PostgREST before, the query DSL is identical.

By default, routes follow the pattern:

GET /api/{schema}/{table}

For the public schema:

GET /api/public/users
GET /api/public/orders

Use the select query parameter:

Terminal window
# Specific columns
curl "http://localhost:3000/api/public/users?select=id,name,email"
# All columns (default)
curl "http://localhost:3000/api/public/users"

Filters use the column=operator.value syntax:

OperatorMeaningExample
eqEqualsname=eq.Widget
neqNot equalsname=neq.Widget
gtGreater thanprice=gt.100
gteGreater or equalprice=gte.100
ltLess thanprice=lt.50
lteLess or equalprice=lte.50
likeLIKE patternname=like.*widget*
ilikeCase-insensitive LIKEname=ilike.*widget*
isIS (null, true, false)deleted_at=is.null
inIN liststatus=in.(active,pending)
Terminal window
# Single column
curl "http://localhost:3000/api/public/items?order=price.desc"
# Multiple columns
curl "http://localhost:3000/api/public/items?order=category.asc,price.desc"
Terminal window
# Limit and offset
curl "http://localhost:3000/api/public/items?limit=10&offset=20"
Terminal window
# Create
curl -X POST "http://localhost:3000/api/public/items" \
-H "Content-Type: application/json" \
-d '{"name": "Widget", "price": 9.99}'
# Update
curl -X PATCH "http://localhost:3000/api/public/items?id=eq.1" \
-H "Content-Type: application/json" \
-d '{"price": 12.99}'
# Delete
curl -X DELETE "http://localhost:3000/api/public/items?id=eq.1"
Terminal window
curl -X POST "http://localhost:3000/api/public/rpc/my_function" \
-H "Content-Type: application/json" \
-d '{"arg1": "value1"}'

Control response behavior with the Prefer header:

Terminal window
# Return the created/updated rows
curl -X POST ... -H "Prefer: return=representation"
# Return only count
curl ... -H "Prefer: count=exact"