Home

Serverless APIs

Supabase auto-generates three types of API directly from your database schema.

  • REST - connect to your database through a restful interface, directly from the browser.
  • GraphQL - manipulate your database using a graph-like query language.
  • Realtime - listen to database changes.

All the APIs are auto-generated from your database and are designed to get you building as fast as possible, without writing a single line of code.

You can use them directly from the browser (two-tier architecture), or as a complement to your own API server (three-tier architecture).

Features#

  • Instant and auto-generated.
    As you update your database the changes are immediately accessible through your API.
  • Self documenting.
    Supabase generates documentation in the Dashboard which updates as you make database changes.
  • Secure.
    The API is configured to work with PostgreSQL's Row Level Security, provisioned behind an API gateway with key-auth enabled.
  • Fast.
    Our benchmarks for basic reads are more than 300% faster than Firebase. The API is a very thin layer on top of Postgres, which does most of the heavy lifting.
  • Scalable.
    The API can serve thousands of simultaneous requests, and works well for Serverless workloads.

REST API #

Supabase provides a RESTful API using PostgREST. This is a very thin API layer on top of Postgres. It provides everything you need from a CRUD API at the URL https://<project_ref>.supabase.co/rest/v1/.

The REST interface is automatically reflected from your database's schema and supports:

  • Basic CRUD operations (Create/Read/Update/Delete)
  • Arbitrarily deep relationships among tables/views, functions that return table types can also nest related tables/views.
  • Works with Postgres Views, Materialized Views and Foreign Tables
  • Works with Postgres Functions
  • User defined computed columns and computed relationships
  • Works with the Postgres security model - including Row Level Security, Roles, and Grants.

The REST API resolves all requests to a single SQL statement leading to fast response times and high throughput.

Reference:

GraphQL API #

Supabase uses pg_graphql to expose a GraphQL API endpoint at https://<project_ref>.supabase.co/graphql/v1/. You can introspect and query the GraphQL API of an existing Supabase project within Studio here, or navigate there manually at API Docs > GraphQL > GraphiQL.

The GraphQL interface is automatically reflected from your database's schema and supports:

  • Basic CRUD operations (Create/Read/Update/Delete)
  • Support for Tables, Views, Materialized Views, and Foreign Tables
  • Arbitrarily deep relationships among tables/views
  • User defined computed fields
  • The Postgres security model - including Row Level Security, Roles, and Grants.

The GraphQL API resolves all requests in a single round-trip leading to fast response times and high throughput.

Reference:

Realtime API #

Supabase provides a Realtime API using Realtime. You can use this to listen to database changes over websockets. Realtime leverages PostgreSQL's built-in logical replication. You can manage your Realtime API simply by managing Postgres publications. Go to your project's Replication section to get started.