Skip to main content

Overview

The Supabase REST API provides full CRUD (Create, Read, Update, Delete) capabilities for your database tables. All endpoints are automatically generated based on your database schema.

Reading Data

Select All Rows

Retrieve all rows from a table.
string
required
Columns to return. Use * for all columns or comma-separated column names.

Response

Select Specific Columns

Only retrieve the columns you need.

Response

Select Single Row

Retrieve a single row by adding a unique filter and using the Accept: application/vnd.pgrst.object+json header.
string
Use application/vnd.pgrst.object+json to return a single object instead of an array.

Response

Filtering

Equality Filters

Comparison Filters

Pattern Matching

List Filters

NULL Filters

Range Filters

Ordering

Sort results by one or more columns.
string
Column name followed by .asc or .desc. Separate multiple with commas.

NULL Ordering

Pagination

Limit and Offset

integer
Maximum number of rows to return.
integer
Number of rows to skip.

Range Header (Preferred)

Use the Range header for more efficient pagination.
string
Range of rows to return (e.g., 0-9 for first 10 rows).

Response Headers

The response includes a Content-Range header showing the range and total count.

Getting Total Count

Get the total number of rows matching your query.
string
Use count=exact to get the total count, count=planned for an estimate, or count=estimated for PostgreSQL’s estimate.

Creating Data

Insert Single Row

string
Use return=representation to return the inserted row, or return=minimal for no content response.

Response (with return=representation)

Insert Multiple Rows

Upsert (Insert or Update)

string
Use resolution=merge-duplicates for upsert behavior. Specify on_conflict parameter for custom conflict columns.

Updating Data

Update Rows

Always include a filter when updating to avoid updating all rows in the table.

Response

Update Multiple Rows

Deleting Data

Delete Rows

Always include a filter when deleting to avoid deleting all rows in the table.

Delete Multiple Rows

Relationships

One-to-Many

Query related data using foreign keys.

Response

Many-to-One

Many-to-Many

Query through junction tables.

Calling Functions

Invoke PostgreSQL functions via RPC.
object
Pass function parameters as a JSON object.

Function Example

Transactions

Perform multiple operations atomically using PostgreSQL functions.
Call via RPC:

Best Practices

Create indexes on columns you frequently filter by:
Reduce payload size by selecting only the columns you need:
Always paginate when dealing with large result sets:
Always enable RLS on your tables and create appropriate policies:

Next Steps

Storage API

Learn about file storage operations

Edge Functions

Call serverless functions