Computing Reviews
Today's Issue Hot Topics Search Browse Recommended My Account Log In
Review Help
Search
High-performance web apps with FastAPI: the asynchronous web framework based on modern Python
Lathkar M., Apress, New York, NY, 2023. 329 pp. Type: Book (978-1484291771)
Date Reviewed: Jan 17 2025

For the software developer seeking to quickly build application programming interfaces (APIs) in Python using a modern approach, this is an excellent resource. The book quickly moves from introductory concepts, assuming some basic knowledge of Python, to the underlying libraries that are utilized in building FastAPI applications, to fully working examples. This enables the reader to skip parts that are familiar, while returning to these for fuller explanations as applications are being developed. The author’s background in teaching is evident from the way the book unfolds--nothing is taken for granted, but the material remains helpful without becoming dense or pedantic.

The first chapter briefly walks the reader through some of the potential pitfalls of using Python to develop web APIs, while avoiding getting bogged down in esoteric details. This should serve to quickly dispel objections to the language itself, such as its dynamic typing and the synchronous Web Server Gateway Interface (WSGI) versus the newer and more performant Asynchronous Server Gateway Interface (ASGI). Performant production applications need strong typing, data validation, and asynchronous processing, which are provided by FastAPI utilizing the Pydantic and Starlette libraries. These are introduced in the first chapter with a working small representational state transfer (REST) API. This is one of the highlights of the approach the author takes in this book--detailed conceptual explanations followed by working code examples that evolve as more advanced concepts are introduced.

The second chapter builds on the simple GET API introduced in chapter 1, to introduce the OpenAPI documentation facilities of FastAPI. The library supports autogenerated OpenAPI documentation out of the box, and visualization using Redoc, running under the Uvicorn ASGI server. This is all explained in a straightforward walkthrough with code examples.

Chapter 3 introduces the Pydantic library for specifying detailed type and validation rules for data models used in API development. There are hints here to the object-relational model (ORM) facilities for tying APIs into backend SQL and NoSQL databases, though that is covered in depth in later chapters.

Chapter 4 is a bit of an aside, delving briefly into the Hypertext Markup Language (HTML) templating facilities that FastAPI also provides. As the author explains, the FastAPI library can be used as a lightweight HTML templating engine.

The next chapters return to the API facilities of the library. Chapter 5 details the response model and its facilities for manipulating cookies and hypertext transfer protocol (HTTP) headers. There is also some helpful information on different response types, including HTML and JSON responses.

Chapter 6 returns to the topic of databases, with substantive material on tying both SQL and NoSQL backend databases into FastAPI applications. This assumes some knowledge of databases, but can also be used as a relatively quick introduction to the facilities available in Python for working with different relational and document databases.

Chapter 7 moves from single-script applications to more typical enterprise applications and their organization, using the APIRouter and dependency injection. There is some space given to middleware as well, which is critical for production-ready applications implementing cross-cutting concerns like logging and cross-origin resource sharing (CORS). Again the author demonstrates these concepts with fully fleshed out example applications.

The next three chapters are the self-described “advanced topics” chapters, but again build on the material already introduced. Chapter 8 delves into working with WebSocket and GraphQL protocols with FastAPI, essential protocols for implementing responsive backend systems. Chapter 9 covers testing, exception handling, and security concerns. This includes a thorough example of implementing OAuth for authentication and authorization. Chapter 10 wraps up the book with a review of deployment options, including a number of cloud solutions for production applications.

As of this writing, the FastAPI library has advanced from v0.79.0 to v0.115.6, but with the thorough explanation and code examples contained in the text, this presented no obstacles to getting from introductory code to advanced API deployments quickly and with very few changes. The author’s background in teaching is evident from the clear style of explanation throughout the book, from the overall structure to the numerous examples and helpful annotations as various concepts are introduced. This should be an excellent resource for Python developers wishing to utilize a faster, asynchronous library to develop web APIs.

More reviews about this item: Goodreads

Reviewer:  Nathan Carlson Review #: CR147871
Bookmark and Share
  Reviewer Selected
 
 
Web (I.7.1 ... )
 
 
APPC/ LU6.2 (C.2.0 ... )
 
 
Python (D.3.2 ... )
 
 
WEB (H.5.3 ... )
 
 
Applications (I.1.4 )
 
 
Applications (I.4.9 )
 
  more  
Would you recommend this review?
yes
no
Other reviews under "Web": Date
Ajax bible
Holzner S., John Wiley & Sons, Inc., New York, NY, 2007.  695, Type: Book (9780470102633)
Mar 5 2008

E-Mail This Printer-Friendly
Send Your Comments
Contact Us
Reproduction in whole or in part without permission is prohibited.   Copyright 1999-2025 ThinkLoud®
Terms of Use
| Privacy Policy