Adding new entries to a Supabase postgres table via REST API
I read this blog post from Jordan on how he created a simple feature request form on his iOS app using Supabase’s Swift library. I wanted to try this out on Python to see how easy would be to implement this when I need a quick way to add a form functionality in a backend service. Here is what I did: Created a free Supabase account . Created a new project. Created a new table in the project and called it feature_request, and added a new column called text. Grabbed the unique API URL and API Key from Project Settings > API. Made an API call in Python: import requests supabase_url = "https://ufcgesssclkrciknuaey.supabase.co" table_name = "feature_request" endpoint = f"{supabase_url}/rest/v1/{table_name}" supabase_key = "<my-supabase-project-api-key>" ## The request will fail if either of apikey or Authorization are not provided headers = { "apikey": supabase_key, "Authorization": f"Bearer {supabase_key}", "Content-Type": "application/json", "Prefer": "return=representation" # This returns the inserted row } data = {"text": "this is a new feature request ..."} response = requests.post(endpoint, json=data, headers=headers) response.json() # [{'id': 1, # 'created_at': '2025-01-02T16:52:44.738549+00:00', # 'text': 'this is a new feature request ...'}] And visiting the table in the Supabase dashboard confirms that the data is inserted as a new row. ...