Build APIs with Flask the right way

What you will learn

Build APIs with Flask following best practices

Create a Flask hello world application

How to choose a good API library

Using flaks-smorest

Implementing data validation models with Marshmallow

Test the API using the Swagger UI

Description

Flask is a hugely popular Python web development framework. Tons of websites are built with Flask, and tons of them contain APIs. I’ve had the privilege to work with many companies building APIs with Flask, I’ve seen many common errors and anti-patterns, and I’ve put together a bunch of best practices to avoid them. This course teaches you how to avoid common mistakes when building APIs with Flask and how to do it the right way.

This course is a quick introduction to building APIs with Flask following best practices and principles. If you know some Flask and are hungry to get started building APIs with Flask, this course is for you. And if you don’t know Flask, don’t worry, we’ll begin by implementing a “hello world” application with Flask so that you understand the basics. You’ll see that it really is very easy to get started with Flask.

Flask is one of Python’s top web development frameworks. We love Flask because it’s lightweight, non-opinionated, very intuitive and easy to use. Flask gives us a lot of flexibility on how to structure our applications and how to implement each layer. However, with great flexibility also comes great responsibility, and this is where things often go astray.


Get Instant Notification of New Courses on our Telegram channel.


That’s especially true for APIs. I’ve seen it myself. You can get going building APIs directly with Flask, returning JSON, parsing and validating request payloads yourself. And before you realise it, you’ve built your own API framework, just not a very good one.

APIs are deceptively simple, and so it’s very tempting to build them without the right tools. Don’t do that. In this course, you’ll learn to build Flask APIs using Flask-smorest, a great Flask plugin for building REST APIs.

English
language

Content

Introduction

Welcome to the course
How to choose a good API library

Setting up the environment

Setting up the virtual environment and installing dependencies
Configuring PyCharm

Hello World with Flask

Implementing a Hello World application with Flask

Setting up Flask-smorest

Setting up flask-smorest
Adding configuration for flask-smorest
Adding an in-memory list of tasks

Implementing the collection endpoints

Implementing the collection endpoints

Implementing Marshmallow models

Implementing data validation models with Marshmallow
Validating URL query parameters with Marshmallow models
Returning data from the /todo/tasks endpoints
Sorting tasks

Implementing the singleton endpoints

Implementing the singleton endpoints
Testing and fixing the singleton endpoints

Wrapping up

Wrapping up