REST API

Creating API Routes

API routes are automatically created when you create Postgres Tables, Views, or Functions.

Create a table

Let's create our first API route by creating a table called todos to store tasks. This creates a corresponding route todos which can accept GET, POST, PATCH, & DELETE requests.

API URL and keys

Every Supabase project has a unique API URL. Your API is secured behind an API gateway which requires an API Key for every request.

  1. Go to the Settings page in the Dashboard.
  2. Click API in the sidebar.
  3. Find your API URL, anon, and service_role keys on this page.

The REST API is accessible through the URL https://<project_ref>.supabase.co/rest/v1

Both of these routes require the anon key to be passed through an apikey header.

Using the API

You can interact with your API directly via HTTP requests, or you can use the client libraries which we provide.

Let's see how to make a request to the todos table which we created in the first step, using the API URL (SUPABASE_URL) and Key (SUPABASE_ANON_KEY) we provided:

JS Reference: select(), insert(), update(), upsert(), delete(), rpc() (call Postgres functions).