iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
💻

Getting Started with Supabase: Hands-on with Auto-generated REST APIs

に公開

What is Supabase?

https://supabase.com/
It is a type of Backend As A Service (BaaS) and positions itself as a Firebase alternative.
It is actually open-source, so it has a public repository on GitHub.
https://github.com/supabase/supabase

There are five main features. This article primarily focuses on the database functionality.

Feature Overview
Database A database using PostgreSQL
Authentication Integrates authentication and access control into apps
Storage Online storage for saving images, videos, etc.
Edge Functions Executes TypeScript functions serverlessly
Realtime Real-time communication between users of the same app

Pricing (As of Feb 2026)

Unlike the pay-as-you-go models of AWS Amplify or Firebase, it follows a subscription model.
There is a Free plan, so it is recommended for those who want to get a feel for BaaS.

Free Pro Team Enterprise
$0/month $25/month $599/month Contact Sales

Detailed differences for each plan are listed on the pricing page.
https://supabase.com/pricing

Strengths and Weaknesses of Supabase

Strengths

  • Costs are easy to predict, reducing the risk of unexpected high cloud bills.
  • REST APIs are automatically generated just by creating tables.
  • It has a simple and easy-to-understand configuration for a BaaS.
  • Row Level Security (RLS) can be easily configured.
  • Self-hosting is possible, reducing the risk of vendor lock-in.

Weaknesses

  • AWS/GCP are stronger at handling high-traffic loads.
  • Since it is not as mature as AWS/GCP, it can be difficult to adopt as core enterprise infrastructure.
  • The flexibility of construction is lower compared to IaaS.
  • The UI is only in English and does not currently support Japanese localization.

What is a REST API?

I have explained this in a previous article, so please refer to that.
https://zenn.dev/lunette/articles/3c8c423e755a54

Hands-on

Prerequisites

  • You must have already created a Supabase account.
  • This hands-on can be performed using the Free plan without any issues.
  • You can find <your_supabase_api_key> on the Settings -> API Keys page.
    • There are two types of API keys, but we will use the default "Publishable key" for this tutorial.
  • Also, replace <your-project> with the Project ID found on the Settings -> General page.

Goal Setting

  • Be able to create a new project.
  • Be able to create a new table using the SQL Editor.
  • Be able to verify the operation of the REST API using the curl command.
  • Confirm the convenience of automatic REST API generation.

Creating a New Project

  1. Click "New project" on the Projects page.

  2. You will be redirected to the new project creation screen. Enter the information as shown in the image below and click "Create new project". For the Database password, you can automatically generate one by clicking "Generate a password".
    Please note that the "Enable Data API" checkbox must be checked. If this is off, the REST API will not be automatically generated.

Creating a New Table

Let's create a new users table using the SQL Editor.
Enter the following SQL statement on the SQL Editor page and click "Run" to create the users table.

CREATE TABLE users (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  user_name TEXT NOT NULL,
  email TEXT,
  age INT,
  phone_number TEXT,
  created_at TIMESTAMPTZ DEFAULT NOW()
);

Testing the REST API

Let's test the REST API using the curl command.
We will verify the operations in the order of POST → GET → PATCH → DELETE.
In Supabase, it is recommended to use PATCH instead of PUT for updates, so we will follow that practice in this hands-on tutorial.

Working Environment

  • Windows 11
  • PowerShell

Creating post001.json

Pre-create the JSON file to be used for the POST method verification.

{
    "user_name": "Nakamura Ryo",
    "email": "ryonakamura@example.com",
    "age": 33,
    "phone_number": "090-1111-1111"
}

As a side note, if the table's id is set as follows, a UUID will be automatically generated, so you don't need to specify an id during the POST.
Also, created_at will automatically be set to the current time, so it doesn't need to be specified either.

Name Type Default Value
id uuid gen_random_uuid()
created_at timestamptz now()

Testing the POST Method

Try running the following curl command in the directory where post001.json is stored.
Note that when using a backtick (`) for line breaks in PowerShell, an error will occur if there is a space immediately following the backtick.

curl.exe -X POST `
-H "Content-Type: application/json" `
-H "apikey: <your_supabase_api_key>" `
-d "@post001.json" `
"https://<your-project>.supabase.co/rest/v1/users"

Testing the GET Method

To verify if the data you just POSTed is actually stored in the users table, run the following curl command. It is successful if data is returned in JSON format.

curl.exe -X GET `
-H "apikey: <your_supabase_api_key>" `
"https://<your-project>.supabase.co/rest/v1/users"

Creating patch001.json

Pre-create the JSON file to be used for the PATCH method verification.

{
    "user_name": "Tanaka Ken",
    "email": "tanakaken@example.com",
    "age": 37,
    "phone_number": "090-9999-9999"
}

Testing the PATCH Method

Let's try to replace the data you verified with the GET method using the PATCH method.
By the way, you can enter the ID you confirmed with the previous GET method in the <UUID> part.
If successful, run the previous GET method once more to confirm if the replacement was correctly applied.

curl.exe -X PATCH `
-H "Content-Type: application/json" `
-H "apikey: <your_supabase_api_key>" `
-d "@patch001.json" `
"https://<your-project>.supabase.co/rest/v1/users?id=eq.<UUID>"

Testing the DELETE Method

Finally, let's verify the operation of the DELETE method.
If successful, run the previous GET method once more to confirm if the contents of the table are empty.

curl.exe -X DELETE `
-H "apikey: <your_supabase_api_key>" `
"https://<your-project>.supabase.co/rest/v1/users?id=eq.<UUID>"

Conclusion

When compared to creating a REST API with AWS, it's clear that the ability to use a REST API immediately after creating a table is a significant advantage in terms of development speed.
It's no exaggeration to say that this is a highly compelling option, particularly for individual developers and small-scale companies.

Supabase adopts the design philosophy of "Database = API," providing a development experience different from traditional API-first cloud architectures.
Since this approach demonstrates high productivity, especially in data-centric applications, it is well worth considering for adoption depending on the characteristics of your project.

Discussion