Python has always been my go-to when building APIs for any of my projects, and in this tutorial, we’re going to build a simple blog application API using FastAPI. We’ll start with structuring our FastAPI project, installing the necessary dependencies, creating our application model structure, writing the functionalities for our application, and finally testing out our API.

<aside> 💡 If you are interested in building something similar using Python Flask, you can check out my 1-hour-long video tutorial on Youtube.

</aside>

Prerequisites

To follow this tutorial, you should have:

  1. Basic knowledge of Python
  2. Basic knowledge of API and how it works.

These are the steps that we will cover:

Step 1 - Project Setup

In this section we will focus on setting up our project, starting with folder creation, environment setup, and installing necessary dependencies.

Folder Creation

On your terminal create a project directory with any name of your choice. In my case I will call my project “anvil-blog”. You can also do this using your computer’s file explorer user interface.

$ mkdir anvil-blog

After creating your application folder, you will need to change your directory into “anvil-blog”.