<?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: Developer's Hub</title>
    <description>The latest articles on Forem by Developer's Hub (@devhub).</description>
    <link>https://forem.com/devhub</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%2F3393714%2F35719153-6bbf-431e-98b7-ac72006b6620.png</url>
      <title>Forem: Developer's Hub</title>
      <link>https://forem.com/devhub</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/devhub"/>
    <language>en</language>
    <item>
      <title>Installation Steps for creating Async APIs using FastAPI</title>
      <dc:creator>Developer's Hub</dc:creator>
      <pubDate>Sun, 04 Jan 2026 05:50:14 +0000</pubDate>
      <link>https://forem.com/devhub/installation-for-async-apis-using-fastapi-3p4m</link>
      <guid>https://forem.com/devhub/installation-for-async-apis-using-fastapi-3p4m</guid>
      <description>&lt;p&gt;To create a backend with &lt;strong&gt;FastAPI&lt;/strong&gt; using asynchronous APIs and &lt;strong&gt;PostgreSQL&lt;/strong&gt;, you will need a set of libraries that support the Python &lt;code&gt;asyncio&lt;/code&gt; event loop. &lt;/p&gt;

&lt;p&gt;For a modern 2026 stack, the following libraries are recommended: &lt;/p&gt;

&lt;p&gt;1. Core Framework &amp;amp; Server &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;&lt;a href="https://fastapi.tiangolo.com/" rel="noopener noreferrer"&gt;FastAPI&lt;/a&gt;&lt;/strong&gt;: The web framework for building your APIs.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;a href="https://uvicorn.dev/" rel="noopener noreferrer"&gt;Uvicorn&lt;/a&gt;&lt;/strong&gt;: An ASGI server required to run your FastAPI application. Use the &lt;code&gt;[standard]&lt;/code&gt; extra for high-performance dependencies like &lt;code&gt;uvloop&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;bash&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install fastapi "uvicorn[standard]"
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Use code with caution.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;2. Database Driver (Async) &lt;/p&gt;

&lt;p&gt;For PostgreSQL specifically, you need an asynchronous driver. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;asyncpg&lt;/strong&gt;: Widely regarded as the fastest asynchronous PostgreSQL client library for Python.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;psycopg (v3)&lt;/strong&gt;: A modern alternative that supports both sync and async operations natively.&lt;/p&gt;

&lt;p&gt;bash&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install asyncpg
# OR
pip install "psycopg[binary]"
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Use code with caution.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;3. ORM &amp;amp; Data Models &lt;/p&gt;

&lt;p&gt;You can use &lt;strong&gt;SQLAlchemy 2.0+&lt;/strong&gt; directly or &lt;strong&gt;SQLModel&lt;/strong&gt;, which combines SQLAlchemy and Pydantic. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;SQLAlchemy&lt;/strong&gt;: Ensure you use the &lt;code&gt;[asyncio]&lt;/code&gt; extra for built-in async support.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;SQLModel&lt;/strong&gt;: A wrapper that simplifies using SQLAlchemy with Pydantic, designed specifically for FastAPI.&lt;/p&gt;

&lt;p&gt;bash&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install "sqlalchemy[asyncio]"
# OR
pip install sqlmodel
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Use code with caution.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;4. Database Migrations &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Alembic&lt;/strong&gt;: The standard tool for handling database schema migrations. While it runs synchronously, it can be configured to work with async drivers in your &lt;code&gt;env.py&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;bash&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install alembic
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Use code with caution.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;5. Utility &amp;amp; Configuration &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;pydantic-settings&lt;/strong&gt;: For managing environment variables and application configurations.&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;python-dotenv&lt;/strong&gt;: To load configuration from &lt;code&gt;.env&lt;/code&gt; files.&lt;/p&gt;

&lt;p&gt;bash&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install pydantic-settings python-dotenv
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Use code with caution.&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Summary Installation Command &lt;/p&gt;

&lt;p&gt;You can install the primary "async stack" with this single command: &lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install fastapi "uvicorn[standard]" "sqlalchemy[asyncio]" asyncpg sqlmodel alembic pydantic-settings
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Use code with caution.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note on Connection Strings:&lt;/strong&gt; When using these libraries, ensure your database URL starts with &lt;code&gt;postgresql+asyncpg://&lt;/code&gt; instead of the standard &lt;code&gt;postgresql://&lt;/code&gt; to trigger the asynchronous engine.&lt;/p&gt;

</description>
      <category>backend</category>
      <category>postgres</category>
      <category>python</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
