Top Rated on Upwork with a 100% Job Success ScoreView on Upwork
retzdev logo
logo
Building a Python API with FastAPI

Python FastAPI: Introduction

by Jarrett Retz

March 2nd, 2021

    Introduction

    This article is the beginning of a series on how to use FastAPI to build an API with Python. Additionally, I'll attach some tools that help to design, develop, and manage the API.

    The API

    The API will use the OpenAPI specification to help with design, documentation, and testing. Its purpose is to help me find and store related articles on my blog.

    Consequently, I'm not sure—yet—how much detail I will go into with the actual code. Furthermore, I won't be available to share the code in a repository. I will share the code that is in each article that may be relevant.

    FastAPI

    FastAPI framework, high performance, easy to learn, fast to code, ready for production

    I heard about FastAPI about a month ago. I'm curious about the framework and want to use this project as an excuse to get to know it better.

    Contrary to the features of FastAPI, I decided to use SwaggerHub to create the OpenAPI specification from scratch (basically).

    I think in the future, I will opt to generate the specification using FastAPI and Python. That will help autogenerate a lot of the syntax.

    Below is a link to the OpenAPI Specification YAML file.

    https://gist.github.com/jdretz/7025f496f64cfbe40b9bd3c44df46655

    Part of the reason that I created this file before creating the Python project is to follow more of an API-first approach. Although, as mentioned, doing these tasks in tandem is a benefit of FastAPI.

    Why API-First?

    Ideally, the OpenAPI specification would be used immediately by the front-end development team to develop the user interface with a mock API. The mock API can easily be generated from the OpenAPI spec.

    Additionally, integration and quality assurance teams could start setting up integration and functional tests based on the mock values.

    This isn't permanent because the specification will change, but it creates an asynchronous approach to developing the API as a whole.

    Next Article

    In the next article, we'll possibly look at:

    • Testing our mock server
    • Setting up the FastAPI project
    Jarrett Retz

    Jarrett Retz is a freelance web application developer and blogger based out of Spokane, WA.

    jarrett@retz.dev

    Subscribe to get instant updates

    Contact

    jarrett@retz.dev

    Legal

    Any code contained in the articles on this site is released under the MIT license. Copyright 2022. Jarrett Retz Tech Services L.L.C. All Rights Reserved.