Chapter 5: Dependency Injections in FastAPI

In this chapter, we'll focus on one of the most interesting parts of FastAPI: dependency injections. You'll see that it is a powerful and readable approach to reuse logic across your project. Indeed, it will allow you to create complex building blocks for your project that you'll be able to use everywhere in your logic. An authentication system, a query parameters' validator, or a rate-limiter are typical use cases for dependencies. In FastAPI, a dependency injection can even call another one recursively, allowing you to build high-level blocks from basic features. By the end of this chapter, you'll be able to create your own dependencies for FastAPI and use them at several levels of your project. ...

Get Building Data Science Applications with FastAPI now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.