chapter two
2 A basic API implementation
This chapter covers
- Reading and understanding the requirements of an API specification
- Structuring our application into a data layer, an application layer, and an interface layer
- Implementing API endpoints using FastAPI
- Implementing data validation models (schemas) using Pydantic
- Testing the API using a Swagger UI
In this chapter, we implement the API for the orders service, which is one of the microservices of the CoffeeMesh website, the project that we introduced in chapter 1. CoffeeMesh is an application that makes and delivers coffee on demand at any time, wherever you are. The orders service allows customers to place orders with CoffeeMesh. As we implement the orders API, you will get an early peek into the concepts and processes that we dissect in more detail throughout this book.
The code for this chapter is available under the folder ch02 of the GitHub repository provided with this book.