<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Yashasvi Singh</title>
    <description>The latest articles on Forem by Yashasvi Singh (@aunicorndev).</description>
    <link>https://forem.com/aunicorndev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F727248%2Fed82575a-3248-4a69-a57e-60077292bc09.jpeg</url>
      <title>Forem: Yashasvi Singh</title>
      <link>https://forem.com/aunicorndev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/aunicorndev"/>
    <language>en</language>
    <item>
      <title>Supa-Fast API (Supabase FastAPI) : Deploying on DETA</title>
      <dc:creator>Yashasvi Singh</dc:creator>
      <pubDate>Wed, 02 Feb 2022 19:22:59 +0000</pubDate>
      <link>https://forem.com/aunicorndev/supa-fast-api-supabase-fastapi-deploying-on-deta-4cjd</link>
      <guid>https://forem.com/aunicorndev/supa-fast-api-supabase-fastapi-deploying-on-deta-4cjd</guid>
      <description>&lt;p&gt;In this last part of the tutorial of the &lt;a href="https://aunicorndev.hashnode.dev/series/supafast-api" rel="noopener noreferrer"&gt;series&lt;/a&gt;,we will be looking at deploying the FastAPI that we build in the &lt;a href="https://aunicorndev.hashnode.dev/supa-fast-api-supabase-fastapi-building-the-api" rel="noopener noreferrer"&gt;last&lt;/a&gt; tutorial.&lt;/p&gt;

&lt;p&gt;We have our Supa-Fast API working on our local system.. But will we be able to deploy it easily????&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwx9u2ds0vy67nl5simw2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwx9u2ds0vy67nl5simw2.png" alt="Deployment  is Fast"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To my surprise, &lt;strong&gt;DETA&lt;/strong&gt; has made it relatively easy to deploy the API..&lt;/p&gt;

&lt;p&gt;I hit some roadblocks while deploying (&lt;strong&gt;OBVIOUSLYYYY&lt;/strong&gt;) and shared a trick that might work for you like it did for me.&lt;/p&gt;

&lt;h2&gt;
  
  
  About Deta
&lt;/h2&gt;

&lt;p&gt;As stated on their &lt;a href="https://docs.deta.sh/docs/home" rel="noopener noreferrer"&gt;official website docs&lt;/a&gt;, &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Deta is a free cloud crafted with the developer and user experience at heart.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  What about Pricing??
&lt;/h3&gt;

&lt;p&gt;It's &lt;strong&gt;FREE.FOREVER&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Yes, their motto states&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;We want anyone, at any age from anywhere in the world to experiment and build their ideas without worrying about limits of credit cards.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Prepare your Local Environment
&lt;/h2&gt;

&lt;p&gt;If you have been following the previous tutorials, we have been using virtualenv and have only a limited dependencies in our virtualenv&lt;/p&gt;

&lt;p&gt;To get the list of installed dependencies for the project , go to the &lt;code&gt;api&lt;/code&gt; directory and run the command&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip freeze &amp;gt; requirements.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This will create a &lt;code&gt;requirements.txt&lt;/code&gt; file in the &lt;code&gt;api&lt;/code&gt; directory.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#requirements.txt

anyio==3.4.0
asgiref==3.4.1
atomicwrites==1.4.0
attrs==21.2.0
certifi==2021.10.8
chardet==4.0.0
charset-normalizer==2.0.8
click==8.0.3
colorama==0.4.4
dataclasses==0.6
deprecation==2.1.0
fastapi==0.70.0
gotrue==0.2.0
h11==0.12.0
httpcore==0.13.7
httptools==0.2.0
httpx==0.19.0
idna==2.10
importlib-metadata==4.8.2
iniconfig==1.1.1
packaging==21.3
pluggy==1.0.0
postgrest-py==0.5.0
py==1.11.0
pydantic==1.8.2
pyparsing==3.0.6
pytest==6.2.5
python-dateutil==2.8.2
python-dotenv==0.19.2
PyYAML==6.0
realtime-py==0.1.3
requests==2.25.1
rfc3986==1.5.0
six==1.16.0
sniffio==1.2.0
starlette==0.16.0
supabase==0.0.3
toml==0.10.2
typing_extensions==4.0.0
urllib3==1.26.7
uvicorn==0.15.0
watchgod==0.7
websockets==9.1
zipp==3.6.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;Make sure you have the &lt;code&gt;.env&lt;/code&gt; file with the environment variables as the API won't get deployed in case you missed that step in the last tutorial.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  Working with DETA
&lt;/h2&gt;

&lt;p&gt;To start, install the DETA CLI in powershell and login into deta using the following commands..&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//The below command for install is for Windows

iwr https://get.deta.dev/cli.ps1 -useb | iex 

deta login


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;To get the list of available commands, run &lt;code&gt;deta --help&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We'll create a new deta micro for the &lt;code&gt;supafast-api&lt;/code&gt; after navigating to the &lt;code&gt;api&lt;/code&gt; folder from the last tutorial&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;deta new
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Response on running deta new command

Successfully created a new micro
{
        "name": "api",
        "id": "XXXX_XXXXX_XXXXX_XXXX_XXXX_XXXX",
        "project": "XXXXXXX",
        "runtime": "python3.9",
        "endpoint": "XXXXXXXXXX",
        "region": "XXXXXXXX",
        "visor": "enabled",
        "http_auth": "disabled"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The above command will install the dependencies listed in the &lt;code&gt;requirements.txt&lt;/code&gt; on our new micro and will be visible on the Deta web interface.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq5lztc37okvq3p347mz4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq5lztc37okvq3p347mz4.png" alt="Installed Packages List"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the previous tutorial, we added a &lt;code&gt;.env&lt;/code&gt; file for the local environment, but for this created Deta instance, we don't have any environment variable defined. To solve that, run the following command while in the &lt;code&gt;api&lt;/code&gt; directory.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;deta update -e .env
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;And our API is available at &lt;a href="https://e5w1sl.deta.dev/docs" rel="noopener noreferrer"&gt;https://e5w1sl.deta.dev/docs&lt;/a&gt; to check out 🤝🤝.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn6f8qrcyitwsb87tkltu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fn6f8qrcyitwsb87tkltu.png" alt="Deta Dashboard"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Your API url can be found on the DETA Dashboard as above.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you want to open up the endpoint to public, run the command&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;deta auth disable

//Response from CLI

Successfully disabled http auth
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Not Getting Any OUTPUT ?????
&lt;/h3&gt;

&lt;p&gt;If you face an error (like me) on running your API in the browser with a response :&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Bad Gateway
The micro ran into an error while processing the request.

If you are the owner of the micro, please check your logs.

If the response took around 10s, it might be due to the time out limit.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Run &lt;code&gt;deta logs&lt;/code&gt; and try if you can find any error in the logs..&lt;/p&gt;

&lt;p&gt;For example, this is the error I got in my logs&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[ERROR] AttributeError: module 'typing' has no attribute '_ClassVar'
Traceback (most recent call last):
  File "/var/lang/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 1030, in _gcd_import
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 1007, in _find_and_load
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 986, in _find_and_load_unlocked
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 680, in _load_unlocked
  File "&amp;lt;frozen importlib._bootstrap_external&amp;gt;", line 850, in exec_module
  File "&amp;lt;frozen importlib._bootstrap&amp;gt;", line 228, in _call_with_frames_removed
  File "/var/task/_entry.py", line 1, in &amp;lt;module&amp;gt;
    from detalib.handler import handle
  File "/opt/python/detalib/handler.py", line 3, in &amp;lt;module&amp;gt;
    from . import handlers
  File "/opt/python/detalib/handlers.py", line 3, in &amp;lt;module&amp;gt;
    from .adapters.asgi import Asgi
  File "/opt/python/detalib/adapters/asgi/__init__.py", line 1, in &amp;lt;module&amp;gt;
    from .adapter import Asgi  # noqa
  File "/opt/python/detalib/adapters/asgi/adapter.py", line 7, in &amp;lt;module&amp;gt;
    from .lifespan import Lifespan
  File "/opt/python/detalib/adapters/asgi/lifespan.py", line 9, in &amp;lt;module&amp;gt;
    class Lifespan:
  File "/opt/python/dataclasses.py", line 958, in dataclass
    return wrap(_cls)
  File "/opt/python/dataclasses.py", line 950, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash, frozen)
  File "/opt/python/dataclasses.py", line 800, in _process_class
    cls_fields = [_get_field(cls, name, type)
  File "/opt/python/dataclasses.py", line 800, in &amp;lt;listcomp&amp;gt;
    cls_fields = [_get_field(cls, name, type)
  File "/opt/python/dataclasses.py", line 659, in _get_field
    if (_is_classvar(a_type, typing)
  File "/opt/python/dataclasses.py", line 550, in _is_classvar
    return type(a_type) is typing._ClassVar
[2021-11-11T00:32:56+05:30] Unknown application error occurred
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;For this particular error, the problem is with the &lt;code&gt;dataclasses&lt;/code&gt; package in the requirements and we will remove it to get the correct output.&lt;/p&gt;

&lt;p&gt;For that, run the following commands&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip uninstall dataclasses

pip freeze &amp;gt;requirements.txt

//run this in powershell
deta deploy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Now on running the Deta Micro with the URL (&lt;a href="https://e5w1sl.deta.dev/themes" rel="noopener noreferrer"&gt;https://e5w1sl.deta.dev/themes&lt;/a&gt;)&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// 20211130191258
// https://e5w1sl.deta.dev/themes

{
  "data": [
    {
      "id": 1,
      "created_at": "2021-11-26T15:28:21+00:00",
      "monsterTheme": "demo-theme-1",
      "monsterThemeBg": "https://jtpcokcjjqbizziufohl.supabase.co/storage/v1/object/public/supafast-api/themes/demo-theme-1.png"
    },
    {
      "id": 2,
      "created_at": "2021-11-26T15:29:45+00:00",
      "monsterTheme": "demo-theme-2",
      "monsterThemeBg": "https://jtpcokcjjqbizziufohl.supabase.co/storage/v1/object/public/supafast-api/themes/demo-theme-2.png"
    },
    {
      "id": 3,
      "created_at": "2021-11-26T15:30:04+00:00",
      "monsterTheme": "demo-theme-3",
      "monsterThemeBg": "https://jtpcokcjjqbizziufohl.supabase.co/storage/v1/object/public/supafast-api/themes/demo-theme-3.png"
    },
    {
      "id": 4,
      "created_at": "2021-11-26T15:30:12+00:00",
      "monsterTheme": "demo-theme-4",
      "monsterThemeBg": "https://jtpcokcjjqbizziufohl.supabase.co/storage/v1/object/public/supafast-api/themes/demo-theme-4.png"
    },
    {
      "id": 6,
      "created_at": "2021-11-26T15:30:21+00:00",
      "monsterTheme": "demo-theme-5",
      "monsterThemeBg": "https://jtpcokcjjqbizziufohl.supabase.co/storage/v1/object/public/supafast-api/themes/demo-theme-5.png"
    }
  ],
  "status_code": 200
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;For more interactive output of the API Documentation, use the URL (&lt;a href="https://e5w1sl.deta.dev/docs" rel="noopener noreferrer"&gt;https://e5w1sl.deta.dev/docs&lt;/a&gt;) which is provided by Swagger UI.&lt;/p&gt;

&lt;p&gt;And as &lt;a href="https://hashnode.com/@FrancescoCiulla" rel="noopener noreferrer"&gt;Francesco&lt;/a&gt; says, NOT DEPLOY on FRIDAY!!!&lt;/p&gt;
&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;With the API deployed, this series comes to an end🎉🎉✨✨.&lt;/p&gt;

&lt;p&gt;In case you have any doubts or suggestions regarding the article(s), feel free to contact me on my email &lt;a href="mailto:aunicorndeveloper@gmail.com"&gt;aunicorndeveloper@gmail.com&lt;/a&gt; or on Twitter at &lt;a href="https://twitter.com/aUnicornDev" rel="noopener noreferrer"&gt;@aUnicornDev&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The API built in this series is used in the tabsMonster project. Everyone is more than welcome to checkout and contribute in this Open Source Project.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/aUnicornDev" rel="noopener noreferrer"&gt;
        aUnicornDev
      &lt;/a&gt; / &lt;a href="https://github.com/aUnicornDev/tabsMonster" rel="noopener noreferrer"&gt;
        tabsMonster
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      A Chrome extension to keep a tab on your Browser Tabs
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;



&lt;h3&gt;
  
  
  Important Links
&lt;/h3&gt;

&lt;p&gt;Below are the links for docs and products if you are more interesed.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.deta.sh/" rel="noopener noreferrer"&gt;https://www.deta.sh/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/deta" rel="noopener noreferrer"&gt;https://github.com/deta&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Deta also has an active community to reach out &lt;a href="https://deta-hq.slack.com/" rel="noopener noreferrer"&gt;Deta Slack&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Thank you for Reading!!
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641799439983%2FZXPsPkl5z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcdn.hashnode.com%2Fres%2Fhashnode%2Fimage%2Fupload%2Fv1641799439983%2FZXPsPkl5z.png" alt="Why are you still here?"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>fastapi</category>
      <category>supabase</category>
      <category>database</category>
      <category>deployment</category>
    </item>
    <item>
      <title>Supa-Fast API (Supabase FastAPI) : Building the API</title>
      <dc:creator>Yashasvi Singh</dc:creator>
      <pubDate>Wed, 12 Jan 2022 16:13:04 +0000</pubDate>
      <link>https://forem.com/aunicorndev/supa-fast-api-supabase-fastapi-building-the-api-4oom</link>
      <guid>https://forem.com/aunicorndev/supa-fast-api-supabase-fastapi-building-the-api-4oom</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;In this is the second part of the &lt;a href="https://aunicorndev.hashnode.dev/series/supafast-api"&gt;series&lt;/a&gt;, we will be looking at building the API using FastAPI and Supabase python client.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Have a database set up on Supabase(can match the database set up in the &lt;a href="https://aunicorndev.hashnode.dev/supabase-fastapi-setting-up-supabase"&gt;last&lt;/a&gt; tutorial)&lt;/li&gt;
&lt;li&gt;Comfortable with Python (including Virtual Environments)&lt;/li&gt;
&lt;li&gt;An Idea  of what Environment Variables are&lt;/li&gt;
&lt;li&gt;JSON format&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Setting up FastAPI
&lt;/h2&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.6+ based on standard Python type hints.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  Installing python 3.7.5
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;To get started , make sure you have python &amp;gt; 3.7 as the latest &lt;code&gt;supabase&lt;/code&gt; client uses that.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Download python 3.7.5 from &lt;a href="https://www.python.org/downloads/release/python-375/"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Install it with the Add to path flag checkbox &lt;strong&gt;enabled&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0CCoBiBx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1641721154772/IUD7ATOSa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0CCoBiBx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1641721154772/IUD7ATOSa.png" alt="Install Python 3.7.5" width="880" height="544"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To list all the installed python on your system use the below command&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; py -0  

Installed Pythons found by C:\Windows\py.exe Launcher for Windows
 -3.7-32 *
 -3.6-32


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Creating test FastAPI
&lt;/h3&gt;

&lt;p&gt;Navigate to the folder where you want to create your project and run the following commands&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir supafast-api

cd .\supafast-api\


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Create and activate a Virtual Environment with the latest installed python using the given commands&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;virtualenv venv-supaFastApi --python=python3.7

.\venv-supaFastApi\Scripts\activate


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Create an &lt;code&gt;api&lt;/code&gt; folder in which the main login for the API will reside.. Name the file as &lt;code&gt;main.py&lt;/code&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: Do not name the file other than &lt;a href="http://main.py/"&gt;main.py&lt;/a&gt; as it is required for deployment.&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir api

cd .\api

cd. &amp;gt;main.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install fastapi

pip install "uvicorn[standard]"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt; &lt;/p&gt; 

&lt;p&gt;In the &lt;code&gt;main.py&lt;/code&gt; file, add the code below and run the API using uvicorn to test if everything works properly.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#main.py

from fastapi import FastAPI

app = FastAPI()


@app.get("/")
def root():
    return {"message": "Hello World Test"}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;uvicorn main:app --reload

http://127.0.0.1:8000/

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;A response similar to this should appear on the screen at &lt;code&gt;http://127.0.0.1:8000/&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// 20211127160738
// http://127.0.0.1:8000/

{
  "message": "Hello World Test"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;blockquote&gt;
&lt;p&gt;TIP : use &lt;a href="https://chrome.google.com/webstore/detail/json-viewer/gbmdgpbipfallnflgajpaliibnhdgobh"&gt;JSON Viewer Chrome Extension&lt;/a&gt; to view prettified JSON in the browser.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now that the test FastAPI is working, let's get started and add the Supabase Python client&lt;br&gt;
to get data in the API.&lt;/p&gt;


&lt;h2&gt;
  
  
  Using Data from Supabase
&lt;/h2&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--566lAguM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/supabase-community"&gt;
        supabase-community
      &lt;/a&gt; / &lt;a href="https://github.com/supabase-community/supabase-py"&gt;
        supabase-py
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Python Client for Supabase
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install supabase
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;We need to use the &lt;code&gt;SUPABASE_URL&lt;/code&gt; as well as &lt;code&gt;SUPABASE_KEY&lt;/code&gt; which will be present in the settings of the Supabase project that we created in the &lt;a href="https://aunicorndev.hashnode.dev/supabase-fastapi-setting-up-supabase"&gt;first&lt;/a&gt; part of this series.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--d8V75Oed--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1641720541476/oZ_nO5JYR.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--d8V75Oed--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1641720541476/oZ_nO5JYR.png" alt="Supabase Keys" width="767" height="705"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#main.py

from fastapi import FastAPI
from supabase import create_client, Client
app = FastAPI()


url = YOUR_SUPABASE_URL
key = YOUR_SUPABASE_KEY

supabase: Client = create_client(url, key)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;h3&gt;
  
  
  Getting Data from Database
&lt;/h3&gt;



&lt;p&gt;This was the structure of the database in the Supabase and for the API ,we are going to add two endpoints in FastAPI...&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  To list down all the themes - &lt;strong&gt;/themes&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;  To list down the monsters of a particular theme - &lt;strong&gt;/monsters/?theme={theme_name}&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#main.py

from fastapi import FastAPI
from supabase import create_client, Client
app = FastAPI()

url = YOUR_SUPABASE_URL
key = YOUR_SUPABASE_KEY

@app.get("/themes")
def themes():
    themes = supabase.table('themes').select('*').execute()
    return themes

@app.get("/monsters/")
def monsters(theme : str = "demo-theme-1"):
    monsters = supabase.table('monsters').select('*').eq('monsterTheme',theme).execute()
    return monsters 


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;For the URL &lt;code&gt;http://127.0.0.1:8000/themes&lt;/code&gt; , the result would be&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// 20211127163945
// http://127.0.0.1:8000/themes

{
  "data": [
    {
      "id": 1,
      "created_at": "2021-11-26T15:28:21+00:00",
      "monsterTheme": "demo-theme-1"
    },
    {
      "id": 2,
      "created_at": "2021-11-26T15:29:45+00:00",
      "monsterTheme": "demo-theme-2"
    },
    {
      "id": 3,
      "created_at": "2021-11-26T15:30:04+00:00",
      "monsterTheme": "demo-theme-3"
    },
    {
      "id": 4,
      "created_at": "2021-11-26T15:30:12+00:00",
      "monsterTheme": "demo-theme-4"
    },
    {
      "id": 6,
      "created_at": "2021-11-26T15:30:21+00:00",
      "monsterTheme": "demo-theme-5"
    }
  ],
  "status_code": 200
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;For the "monsters" endpoint, we need a query parameter, but in case we don't send a query parameter, we will have a default value set so that a response is available at the endpoint.&lt;/p&gt;

&lt;p&gt;In the &lt;code&gt;main.py&lt;/code&gt; above , we have a default set to &lt;em&gt;demo-theme-1&lt;/em&gt;.. So in case the API call is to the endpoint &lt;code&gt;http://127.0.0.1:8000/monsters/&lt;/code&gt; we will get the result as follows&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// 20211129131036
// http://127.0.0.1:8000/monsters/

{
  "data": [
    {
      "id": 1,
      "created_at": "2021-11-27T02:47:11+00:00",
      "monsterName": "demo-monster-1",
      "monsterQuote": "demo-quote-1",
      "monsterTheme": "demo-theme-1",
      "monsterLevel": 5
    },
    {
      "id": 2,
      "created_at": "2021-11-27T02:49:03+00:00",
      "monsterName": "demo-monster-2",
      "monsterQuote": "demo-quote-2",
      "monsterTheme": "demo-theme-1",
      "monsterLevel": 10
    },
    {
      "id": 4,
      "created_at": "2021-11-27T02:50:21+00:00",
      "monsterName": "demo-monster-3",
      "monsterQuote": "demo-quote-3",
      "monsterTheme": "demo-theme-1",
      "monsterLevel": 20
    }
  ],
  "status_code": 200
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Getting Images from Storage
&lt;/h3&gt;

&lt;p&gt;The Supabase Python Client also provides various methods to interact with the Supabase Storage and we are going to get the public URL for the stored images.&lt;/p&gt;

&lt;p&gt;For that we need to have the exact location of the file in the Bucket as well as the correct name for the images.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--p0fz3r_v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1640292359675/cwj3C-fL6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--p0fz3r_v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1640292359675/cwj3C-fL6.png" alt="image.png" width="842" height="429"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;From the last blog of the series, we had the above structure of files in the Bucket &lt;code&gt;supafast-api&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#main.py

from fastapi import FastAPI
from supabase import create_client, Client
app = FastAPI()

url = YOUR_SUPABASE_URL
key = YOUR_SUPABASE_KEY

supabase: Client = create_client(url, key)

@app.get("/themes")
def themes():
    themes = supabase.table('themes').select('*').execute()

    for theme in themes['data']:
#theme['monsterThemeBg'] = supabase.storage().StorageFileAPI(BUCKET_NAME).get_public_url(FILE_LOCATION)
        theme['monsterThemeBg'] = supabase.storage().StorageFileAPI('supafast-api').get_public_url('themes/'+ theme['monsterTheme'].replace(' ','-') + '.png')

    return themes


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Here, the &lt;em&gt;FILE_LOCATION&lt;/em&gt;  is easier to construct because the way these files are stored. The response we receive after adding the &lt;code&gt;monsterThemeBg&lt;/code&gt; is like&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// 20211129184109
// http://127.0.0.1:8000/themes

{
  "data": [
    {
      "id": 1,
      "created_at": "2021-11-26T15:28:21+00:00",
      "monsterTheme": "demo-theme-1",
      "monsterThemeBg": "https://jtpcokcjjqbizziufohl.supabase.co/storage/v1/object/public/supafast-api/themes/demo-theme-1.png"
    },
    {
      "id": 2,
      "created_at": "2021-11-26T15:29:45+00:00",
      "monsterTheme": "demo-theme-2",
      "monsterThemeBg": "https://jtpcokcjjqbizziufohl.supabase.co/storage/v1/object/public/supafast-api/themes/demo-theme-2.png"
    },

    ...


  ],
  "status_code": 200
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;The final &lt;code&gt;main.py&lt;/code&gt; file will look something like this..&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#main.py

from fastapi import FastAPI
from supabase import create_client, Client
app = FastAPI()

url = YOUR_SUPABASE_URL
key = YOUR_SUPABASE_KEY
supabase: Client = create_client(url, key)


@app.get("/themes")
def themes():
    themes = supabase.table('themes').select('*').execute()
    print(themes['data'])
    for theme in themes['data']:
        theme['monsterThemeBg'] = supabase.storage().StorageFileAPI('supafast-api').get_public_url('themes/'+ theme['monsterTheme'] + '.png')

    return themes

@app.get("/monsters/")
def monsters(theme : str = "demo-theme-1"):
    monsters = supabase.table('monsters').select('*').eq('monsterTheme',theme).execute()
    for monster in monsters['data']:
        monster['monsterBg'] = supabase.storage().StorageFileAPI('supafast-api').get_public_url(monster['monsterTheme']+'/'+ monster['monsterName'].replace(' ','-') + '.png')

    return monsters


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Setting Up Environment Variables
&lt;/h2&gt;

&lt;p&gt;As you can see in the &lt;code&gt;main.py&lt;/code&gt; , &lt;em&gt;SENSITIVE properties&lt;/em&gt; like the url and key are directly defined in the file. Such sensitive data should never be in a file and to overcome it, we use &lt;strong&gt;environment variables.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I found this really good article on &lt;a href="https://dev.to/jakewitcher/using-env-files-for-environment-variables-in-python-applications-55a1"&gt;dev.to&lt;/a&gt; to use environment variables from a &lt;code&gt;.env&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;To do that,&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Stop the uvicorn server

cd. &amp;gt;.env 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Now in the newly created &lt;code&gt;.env&lt;/code&gt; file, add your variables in the format&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#.env

SUPABASE_SUPAFAST_URL=your-supabase-url
SUPABASE_SUPAFAST_KEY=you-supabase-key

#make sure you don't have spaces before/after the equal sign
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;In &lt;code&gt;main.py&lt;/code&gt; file,&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import os
from fastapi import FastAPI
from supabase import create_client, Client
from dotenv import load_dotenv

load_dotenv()
app = FastAPI()

url = os.getenv('SUPABASE_SUPAFAST_URL')
key = os.getenv('SUPABASE_SUPAFAST_KEY')
supabase: Client = create_client(url, key)

'''
Rest of the code for the routes of the API
'''



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Here, we additionally import the &lt;code&gt;os&lt;/code&gt; and the &lt;code&gt;load_dotenv&lt;/code&gt; packages, run the &lt;code&gt;load_dotenv()&lt;/code&gt; function which loads the &lt;em&gt;KEY=VALUE&lt;/em&gt;  pairs into the environment so that &lt;code&gt;os.getenv('KEY')&lt;/code&gt; can retrieve the value from the environment.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;We didn't need to install a package for load_dotenv because the &lt;code&gt;python-dotenv&lt;/code&gt; gets automatically installed when running pip install "uvicorn[standard] "&lt;/p&gt;
&lt;/blockquote&gt;



&lt;p&gt;In case you use git(or some other VCS), make sure to put the &lt;code&gt;.env&lt;/code&gt; in the &lt;code&gt;.gitignore&lt;/code&gt; file, so that it is not visible to the general public.&lt;/p&gt;


&lt;h2&gt;
  
  
  Next Steps
&lt;/h2&gt;

&lt;p&gt;Now that we have our API fully working on our local environment, in the next tutorial will deploy it on &lt;strong&gt;DETA&lt;/strong&gt; and make it available publicly.&lt;/p&gt;

&lt;p&gt;In case you have any doubts or suggestions regarding the article, feel free to contact me on my email &lt;a href="mailto:aunicorndeveloper@gmail.com"&gt;aunicorndeveloper@gmail.com&lt;/a&gt; or on Twitter at &lt;a href="https://twitter.com/aUnicornDev"&gt;@aUnicornDev&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The API built in this series is used in the tabsMonster project. Everyone is more than welcome to checkout and contribute in this Open Source Project.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--566lAguM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/aUnicornDev"&gt;
        aUnicornDev
      &lt;/a&gt; / &lt;a href="https://github.com/aUnicornDev/tabsMonster"&gt;
        tabsMonster
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      A Chrome extension to keep a tab on your Browser Tabs
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;



&lt;h3&gt;
  
  
  Important Links
&lt;/h3&gt;

&lt;p&gt;Below are the links for docs and products if you are more interesed.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.python.org/downloads/release/python-375/"&gt;Python 3.7.5&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;

&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--566lAguM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/github-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/tiangolo"&gt;
        tiangolo
      &lt;/a&gt; / &lt;a href="https://github.com/tiangolo/fastapi"&gt;
        fastapi
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      FastAPI framework, high performance, easy to learn, fast to code, ready for production
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://chrome.google.com/webstore/detail/json-viewer/gbmdgpbipfallnflgajpaliibnhdgobh"&gt;JSON Viewer Chrome Extension&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Thank you for reading this far
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--aCO9jaVR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1641723425513/UgtR-nqeN.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--aCO9jaVR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1641723425513/UgtR-nqeN.png" alt="image.png" width="443" height="250"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>python</category>
      <category>database</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Supa-Fast API(Supabase FastAPI): Setting up Database and Storage</title>
      <dc:creator>Yashasvi Singh</dc:creator>
      <pubDate>Fri, 07 Jan 2022 18:58:42 +0000</pubDate>
      <link>https://forem.com/aunicorndev/supa-fast-apisupabase-fastapi-setting-up-database-and-storage-1bd4</link>
      <guid>https://forem.com/aunicorndev/supa-fast-apisupabase-fastapi-setting-up-database-and-storage-1bd4</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This tutorial is the First of a Three part series on Building a FastAPI with Supabase as the backend and Deploying it on deta.sh&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;&lt;strong&gt;Supabase is an Open Source  Firebase Alternative&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this tutorial, we will be setting up &lt;strong&gt;&lt;em&gt;Supabase&lt;/em&gt;&lt;/strong&gt; from scratch and there are going to be a &lt;strong&gt;ton of screenshots&lt;/strong&gt; for reference ahead, so brace yourselves!!!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fphjiqdhgncckxo149yhi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fphjiqdhgncckxo149yhi.png" alt="Few ways you can use Print Screen Button"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Getting Started with Supabase
&lt;/h2&gt;

&lt;p&gt;Jump on to &lt;a href="https://supabase.com/" rel="noopener noreferrer"&gt;Supabase&lt;/a&gt; ,click on Start your project and login with GitHub&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyz6pfy75jul7v1ryq2un.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyz6pfy75jul7v1ryq2un.png" alt="Supabase - Start your Project"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5gk6uis47s89fdgry20x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5gk6uis47s89fdgry20x.png" alt="Supabase - Login with GitHub"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Start a &lt;code&gt;New Project&lt;/code&gt; and an empty database will be available for you to start adding tables.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2yjz178jjtabhtoaxuv5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2yjz178jjtabhtoaxuv5.png" alt="Create a New project"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fej7yojur5ajrwh3tuzrn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fej7yojur5ajrwh3tuzrn.png" alt="Using Database and Storage Functionality"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;We will be using the &lt;strong&gt;Database&lt;/strong&gt; and &lt;strong&gt;Storage&lt;/strong&gt; functionality for this API as highlighted above and we'll start by adding a couple of tables in the Database.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Setting Up Database
&lt;/h2&gt;

&lt;p&gt;For reference ahead, we will be making the following relationship between our tables.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7739zcdz8wgx7lqrjkr4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7739zcdz8wgx7lqrjkr4.png" alt="database Mockup"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This mockup is made in &lt;a href="https://drawsql.app/none-390/diagrams/supafast-api" rel="noopener noreferrer"&gt;drawsql&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  themes Table
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffp866fgo2apfsv4fif2r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffp866fgo2apfsv4fif2r.png" alt="Create a New table"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Start by creating a new table...&lt;/p&gt;

&lt;p&gt;Here, in table named themes, we have enabled the &lt;em&gt;is Unique&lt;/em&gt; flag in the &lt;code&gt;monsterTheme&lt;/code&gt; as we have to use the &lt;code&gt;monsterTheme&lt;/code&gt; as a FOREIGN KEY in the &lt;code&gt;monsters&lt;/code&gt; table as shown in the mockup above.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5rrvp3wmpeic2c8wah1x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5rrvp3wmpeic2c8wah1x.png" alt="Set the IsUnique as true"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqpjmpka95fxym5x0vry9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqpjmpka95fxym5x0vry9.png" alt="Add New rows to themes table"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After inserting a few rows of Dummy/Demo data in the table &lt;code&gt;themes&lt;/code&gt; like we did above, we can see a similar table in the Database.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwbprc0cx7gs5rjlqt47v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwbprc0cx7gs5rjlqt47v.png" alt="themes table overview"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  monsters Table
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7cun6bgd104eo60117oq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7cun6bgd104eo60117oq.png" alt="Using FOREIGN KEY in monsters table"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A &lt;code&gt;FOREIGN KEY&lt;/code&gt; can be added on the database by clicking on the link button which will open up the choices for the table and it's underlying columns.&lt;/p&gt;

&lt;p&gt;We have the &lt;code&gt;themes&lt;/code&gt; as the desired table and &lt;code&gt;monsterTheme&lt;/code&gt; as the column which will act a &lt;code&gt;FOREIGN KEY&lt;/code&gt; in the table &lt;code&gt;monsters&lt;/code&gt; .&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkq26b6nwr3565q1se12w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkq26b6nwr3565q1se12w.png" alt="Selecting the table and column for the Foreign Key"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Similar to themes, we will insert some Dummy data into the &lt;code&gt;monsters&lt;/code&gt; table.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhkmxa253ubsbc9js2ll3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhkmxa253ubsbc9js2ll3.png" alt="Add New Row to monsters table"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9onmnkyg9qhhg85n6t13.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9onmnkyg9qhhg85n6t13.png" alt="Monsters table Overview"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With the Databases set up with some initial dummy data, we can finally move on to the Supabase Storage.&lt;/p&gt;
&lt;h2&gt;
  
  
  Setting up Storage
&lt;/h2&gt;

&lt;p&gt;Supabase Storage has 3 important keywords&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Files&lt;/strong&gt; : Any sort of media file&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Folder&lt;/strong&gt; : A way to organize the files in a more meaningful manner&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Bucket&lt;/strong&gt; : A Super Folder under which all related folders should be kept&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We'll be creating a new Bucket named &lt;strong&gt;supafast-api&lt;/strong&gt; for storing the &lt;code&gt;theme background&lt;/code&gt; as well as the &lt;code&gt;monster images&lt;/code&gt; .&lt;/p&gt;

&lt;p&gt;We'll also be adding a number of Folders to structure these image so that we can retrieve them in the API easily.&lt;/p&gt;

&lt;p&gt;Under Storage in the left menu bar, Create a new &lt;em&gt;public&lt;/em&gt; Bucket name &lt;code&gt;supafast-api.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffqc3uxa20nasiodlo2zm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffqc3uxa20nasiodlo2zm.png" alt="Start with creating a New Bucket"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Create a folder named &lt;code&gt;themes&lt;/code&gt; and a folder for every theme name.&lt;/p&gt;

&lt;p&gt;The themes folder contains images for the theme background whereas the theme names contain images for the underlying monsters.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdrsdp3qxk9j9oyeo4isg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdrsdp3qxk9j9oyeo4isg.png" alt="Folder and File structure in the storage bucket"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And we are done with setting up the &lt;strong&gt;Database&lt;/strong&gt; as well as the &lt;strong&gt;Storage&lt;/strong&gt; for the database.&lt;/p&gt;

&lt;p&gt;In the upcoming blogs of this series, we will look at building and deploying an API with &lt;a href="https://fastapi.tiangolo.com/" rel="noopener noreferrer"&gt;FastAPI&lt;/a&gt; using the Supabase Client for Python.&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;Below are the links for docs and products if you are more interesed.&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://supabase.com/docs" rel="noopener noreferrer"&gt;Supabase Docs&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Supabase also has an amazing &lt;a href="https://discord.gg/dNgwGxwRRw" rel="noopener noreferrer"&gt;discord&lt;/a&gt; community to learn and have fun.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://drawsql.app/" rel="noopener noreferrer"&gt;drawSql&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;



&lt;p&gt;The API built in this series is used in the tabsMonster project. Everyone is more than welcome to checkout and contribute in this Open Source Project. &lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/aUnicornDev" rel="noopener noreferrer"&gt;
        aUnicornDev
      &lt;/a&gt; / &lt;a href="https://github.com/aUnicornDev/tabsMonster" rel="noopener noreferrer"&gt;
        tabsMonster
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      A Chrome extension to keep a tab on your Browser Tabs
    &lt;/h3&gt;
  &lt;/div&gt;
&lt;/div&gt;





&lt;h3&gt;
  
  
  Thank you for reading this far
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzje79bzb86jh3kciqbi0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzje79bzb86jh3kciqbi0.png" alt="Thank You"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>database</category>
      <category>sideprojects</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
