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 theAccept: 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 theRange header for more efficient pagination.
string
Range of rows to return (e.g.,
0-9 for first 10 rows).Response Headers
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
Response
Update Multiple Rows
Deleting Data
Delete Rows
Delete Multiple Rows
Relationships
One-to-Many
Query related data using foreign keys.Response
Many-to-One
Many-to-Many
Query through junction tables.Filtering on Related Data
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.Best Practices
Use indexes for filtered columns
Use indexes for filtered columns
Create indexes on columns you frequently filter by:
Select only needed columns
Select only needed columns
Reduce payload size by selecting only the columns you need:
Use pagination for large datasets
Use pagination for large datasets
Always paginate when dealing with large result sets:
Enable Row Level Security
Enable Row Level Security
Always enable RLS on your tables and create appropriate policies:
Next Steps
Storage API
Learn about file storage operations
Edge Functions
Call serverless functions
