
FastAPI is one of the newest and most popular API frameworks for Python developers. Time and again, we engineers need to use one or more third-party libraries with our APIs for appending additional functionalities and features to enrich our projects.Â
In this article today, I want to share with you some of those resources that are extremely useful for regular FastAPI practitioners. I have used most of them in my own projects, and am also including a few that I’m planning on using in the near future.Â
So let’s dive in and take a look!Â
FastAPI-pagination
This library allows you to send simple, paginated responses from your API routes. This is massively convenient to use in a few lines of code in your main.py rather than writing the entire pagination logic yourself.Â
I also recently used this library in my full-stack tutorial series, which you can check out here: A Full-Stack Project With React and FastAPI — Part 2
Checkout the library here:Â https://github.com/uriyyo/fastapi-pagination
FastAPI-MVC
This is an extremely convenient Python developer productivity tool for making high-quality FastAPI production-ready APIs starting from a single shell command.Â
You get all the boilerplate setup for a MVC Python project and can get straight to writing your project specific code by utilizing the generators defined within this library.Â
Things you get out of the box include:Â
Python Poetry dependency management
Makefile, GitHub actions, and Docker setup
Ready made Sphinx documentationÂ
and much more.Â
Checkout the library here:Â https://github.com/fastapi-mvc/fastapi-mvc
FastAPI-Mail
As you might’ve guessed already from the name, this is a lightweight library to help you easily send mails from your FastAPI project, and has built-in support for background task management.Â
You can send both text and file based emails with this library, thus allowing you to not reinvent the wheel in writing the logic yourself.Â
Checkout the library here:Â https://github.com/sabuhish/fastapi-mail
If you’re enjoying this post and want to receive more tutorials and lists like these regularly, consider subscribing:
Tortoise-ORM
If you’re someone like me and were extremely used to the built-in ORM in Django and felt flatfooted in working in FastAPI, you’ll not be disappointed after checking out this library.Â
This is an ORM inspired by Django helping you work in a Django-esque manner with relational databases of your choice.Â
Checkout the library here:Â
https://tortoise.github.io/#why-was-tortoise-orm-built
FastAPI-Cache
Building production-grade APIs require a number of additional requirements such as a working cache. This library allows you to integrate caches like Redis and memcache to cache FastAPI response and function results very conveniently.
Additionally, it even has the AWS Dynamo-DB support for storing your cache!Â
Checkout the library here:Â https://github.com/long2ice/fastapi-cache
FastAPI-Limiter
One of the easiest and simplest ways to prevent abuse of your production API routes is through the process of rate-limiting. This library allows you to easily integrate rate limiting through simple Python decorators in your FastAPI routes.Â
It also has support for web sockets, which is an additional feature that employs rate limiting pertaining to data exchanged through the socket.Â
Checkout the library here:Â https://github.com/long2ice/fastapi-limiter
FastAPI-Admin
Django’s admin interface is one of the coolest out-of-the-box features that once again, is missing in FastAPI. This library, as you might’ve guessed, fulfills that requirement quite nicely.Â
It uses a Bootstrap HTML template as the admin / dashboard UI for making the admin interface for your FastAPI project.Â
Checkout the library here:Â https://github.com/fastapi-admin/fastapi-admin
FastAPI Best Practises
Best practises in any production-ready system can include a large number of checks to fulfil. Gathering those requirements yourself can be tedious and there is a good chance of missing out on some critical step in the process.Â
This repository is a collection of comprehensive set of best practises that you can choose to employ in your FastAPI projects.Â
Checkout the repository here:Â https://github.com/zhanymkanov/fastapi-best-practices
FastAPI with message queues and monitoring
RabbitMQ is one of the most popular message brokers out there and if you want to integrate it with your FastAPI project, look no further than this boilerplate GitHub repository.
It even includes a convenient Celery setup for monitoring tasks with an integrated Redis backend. Quite amazing!
Checkout the library here:Â https://github.com/GregaVrbancic/fastapi-celery
A few parting words…
Thank you for reading this list of some of the most useful FastAPI frameworks I’ve found useful.Â
I hope you’ll find this helpful for your future projects as well.
Share this issue with a friend if you’d like!