This is the code repository for Building Python Web APIs with FastAPI, published by Packt.
A fast-paced guide to building high-performance, robust web APIs with very little boilerplate code
RESTful web services are commonly used to create APIs for web-based applications owing to their light weight and high scalability. This book will show you how FastAPI, a high-performance web framework for building RESTful APIs in Python, allows you to build robust web APIs that are simple and intuitive and makes it easy to build quickly with very little boilerplate code.
This book covers the following exciting features:
- Set up a FastAPI application that is fully functional and secure
- Understand how to handle errors from requests and send proper responses in FastAPI
- Integrate and connect your application to a SQL and NoSQL (MongoDB) database
- Perform CRUD operations using SQL and FastAPI
- Manage concurrency in FastAPI applications
If you feel this book is for you, get your copy today!
All of the code is organized into folders. For example, Chapter05.
The code will look like the following:
from pydantic import BaseModel
from typing import List
class Event(BaseModel):
id: int
title: str
image: str
description: str
tags: List[str]
location: str
Following is what you need for this book:
This book is for Python developers who want to learn FastAPI in a pragmatic way to create robust web APIs with ease. If you are a Django or Flask developer looking to try something new that's faster, more efficient, and produces fewer bugs, this FastAPI Python book is for you. The book assumes intermediate-level knowledge of Python programming.
With the following software and hardware list you can run all code files present in the book (Chapter 1-09).
Chapter | Software required | OS required |
---|---|---|
1-09 | Python 3.10 | Windows, Mac OS X, and Linux |
1-09 | Git 2.36.0 | Windows, Mac OS X, and Linux |
We also provide a PDF file that has color images of the screenshots/diagrams used in this book. Click here to download it.
- Use port 8000 as per the GitHub repository examples.
- Page 14 (Code Snippet 1 line 1): FROM PYTHON:3.8 should be FROM python:3.8
- Page 15 (last line): FROM PYTHON:3.8 should be (venv)$ uvicorn api:app --port 8080 --reload
- Page 10,11,12 : Page 10 should display the picture of page 11. Page 11 should display the picture of page 12. Page 12 should display the picture of page 10.
- Page 24, (Code snippet 2 Line 1):
from Pydantic import BaseModel
should befrom pydantic import BaseModel
- Page 24, (Code snippet 2 Line 2):
class Todo(BaseMode):
should beclass Todo(BaseModel):
- Page 24, (Code snippet 2 Line 2):
- Page 24, Let’s go ahead and use the model in our POST route. In api.py, import the model should be Let’s go ahead and use the model in our POST route. In todo.py, import the model
Abdulazeez Abdulazeez Adeshina is a skilled Python developer, backend software engineer, and technical writer, with a wide range of technical skill sets in his arsenal. His background has led him to build command-line applications, backend applications in FastAPI, and algorithm-based treasure-hunting tools. He also enjoys teaching Python and solving mathematical-oriented problems through his blog. Abdulazeez is currently in his penultimate year of a water resources and environmental engineering program. His work experience as a guest technical author includes the likes of Auth0, LogRocket, Okteto, and TestDriven.
If you have already purchased a print or Kindle version of this book, you can get a DRM-free PDF version at no cost.
Simply click on the link to claim your free PDF.