Introduction to Python API Building

Python is a powerful programming language with many applications. In this post we will explore its ability to build REST APIs. We will leverage the FastAPI, Pydantic, and SQLAlchemy python libraries, along with Postgres to build a REST API that can support a simple TODO list application. By the end of this tutorial, you will have a working understanding on how to build a Python web application with simple database interactions.

Project Description

For this project we will be implementing a REST API for a todo application. We will provide the ability to create, read, update, and delete, also known as CRUD operations, for the todo items.

Project Setup

If you’d like to follow along with this post you will need to have the following tools in your environment.

We will be using docker to spin up a temporary Postgres instance for our application to connect to. Pycharm and Datagrip are the IDEs that I prefer to use, but you can swap them out for whatever you are comfortable with. All the source code for this project can be found on github.

TODO List API

Database

Before we can build any REST application, it is important that we have the ability to persist our application’s data. For this project we will be using a postgres database consisting of one table. But before we get too far ahead of ourselves, let’s spin up the database and connect to it!

Read More

Tags: API Python