REST API

An instant REST API from your schema

Every table and view in the public schema is available over HTTPS as soon as you create it — filtering, ordering, pagination, relations and RPC included. Row Level Security runs on every request.

const { data, error } = await stitchdb
  .from('todos')
  .select('id, task, is_complete')
  .eq('is_complete', false)
  .order('created_at', { ascending: false })
  .range(0, 9)

What you get

Endpoints without backend code

No backend code

Create a table, get endpoints. Insert, update and delete with JSON bodies.

Filters and pagination

eq, gt, order, limit, offset and range(); up to 1,000 rows per request on Free and 5,000 on Pro.

Call functions

Postgres functions in public are callable with rpc() or POST /rest/v1/rpc/<name>.

In the dashboard

REST API in your project dashboard

A real screen from the StitchDB dashboard.

stitchdb.com/dashboard/project/…/api
Generated API documentation for a table with JavaScript examples Generated API documentation for a table with JavaScript examples

How it works

Get started with REST API

  1. Send your key

    Put the anon key in the apikey header; add a user's access token as a bearer token to act as that user.

  2. Query

    GET /rest/v1/todos?select=id,task&is_complete=eq.false.

  3. Get rows back

    Add Prefer: return=representation to receive changed rows.

Requests
GET    /rest/v1/todos?select=*                        List rows
GET    /rest/v1/todos?is_complete=eq.true&id=gt.10    Filter
GET    /rest/v1/todos?order=created_at.desc&limit=20  Order and paginate
POST   /rest/v1/todos                                 Insert (JSON body)
PATCH  /rest/v1/todos?id=eq.1                         Update
DELETE /rest/v1/todos?id=eq.1                         Delete
POST   /rest/v1/rpc/function_name                     Call a function

Example

See it in code

await stitchdb.from('todos').insert({ task: 'Write docs' })

await stitchdb.from('todos').update({ is_complete: true }).eq('id', 1)

await stitchdb.from('todos').delete().eq('id', 1)

Start building on StitchDB today

Create your first project in under a minute.