Our Journey Using Async FastAPI to Harnessing the Power of Modern Web APIs

Jonathan Vargas
Allient
Published in
4 min readAug 14, 2023

In the ever-evolving landscape of web development, staying ahead requires embracing innovative tools and practices that can reshape the way we approach projects. This post serves as a testament to the transformative power of FastAPI and the paradigm shift it brought to our team’s work process. By sharing our journey of adopting Async FastAPI, we aim to inspire fellow developers and teams to explore the potential of this cutting-edge framework. It also offers a practical template that showcases how currently our teams use this awesome framework.

Learn something new. Try something different. Convince yourself that you have no limits.”- Brian Tracy

Photo by Tim Mossholder on Unsplash

Why did we start using Fastapi?

It was late 2021, and our development team had been accustomed to the familiar landscapes of Python web frameworks like Django and Flask. However, as we embarked on a new project, a novel requirement emerged — seamless integration of asynchronous support. This single demand transformed our exploration into a quest for the ideal framework that could cater to this need while delivering exceptional performance and flexibility. That’s when we first encountered FastAPI. It stood out as a game-changer, not only for its touted asynchronous capabilities but also for its fresh approach to modern web development. Looking back, almost two years later, I can confidently affirm that it stands as one of the finest decisions our team has made.

Understanding asynchronous concepts might initially pose challenges, there are concepts like concurrency and parallelism. While other languages have embraced these concepts, Python too began incorporating some of these concepts to harness their benefits after its version 3.5 in 2015. In essence, asynchronous programming enhances efficiency, responsiveness, and resource utilization. I really recommend checking this reference to get a better understanding of async concepts. Also why Python is not multithreading and some efforts to improve this situation.

Starting using FastAPI

Our journey with FastAPI began by immersing ourselves in its documentation, navigating through FastAPI’s documentation proved to be a treasure trove of knowledge not just about FaspAPI but also about backend concepts I really recommend anyone to take their time to read it.

FastAPI left an indelible first impression on our team, primarily due to its remarkably approachable learning curve. It's improved speed in a Python environment. This was just the tip of the iceberg.

We found that FastAPI promotes good coding practices and standards like OpenAPI and awesome Python tools like Pydantic schemas. It was really beneficial for our team and it was like a virus that infect us to improve the way we were writing Python code.

The transition from Postman to OpenAPI marked a pivotal moment. This strategic move not only streamlined our API testing processes but also established enhanced collaboration channels with our frontend team, enabling smoother API integration.

As we dive more into this framework we started looking for other tools that have async support to interface with databases and async tasks. We learned that the best when working in async is to try to use all packages with async compatibility to avoid blocking I/O. Because backend development involves interfacing with tools like databases, other APIs, and third-party services the recommended id is that they work async, or if they work just sync search a way to make them work async like using asyncer.

In this journey, we scoured various GitHub repositories to glean insights from other projects some of the more remarkable were:

In my opinion, one of FastAPI’s differentiators lay in its vibrant and tightly-knit community, led by tiangolo (Sebastián Ramírez). It is really awesome to say that you are using fastapi in any project.

https://www.kumospace.com/blog/teamwork-memes

If you’re considering FastAPI for your next project, I wholeheartedly recommend taking that step. FastAPI is not just a tool, but a catalyst for efficient, innovative, and collaborative-driven development.

As we began using FastAPI in our projects, we found ourselves repeatedly setting up folder structures and configurations. This prompted us to recognize the need for a template that could serve as a guiding resource. This template would streamline the process of configuring new projects with the tools we were accustomed to using frequently, eliminating the need to recreate the setup from scratch each time. This post contains 0 lines of code, but you can find thousands in this sample project that our team creates as a result of a lot of work and time using fastapi here.

Thanks for your time reading this post 😃 !!

Feel free to give me your feedback and comments and if you want me to cover another topic please let me know in the comments. You can also subscribe 👍 to our newsletter to receive post like this😄.

Do you need some help with a project?

We are ready to listen to you. If you need some help, you can contact our team at info@allient.io or schedule a meeting with us here.

--

--

Jonathan Vargas
Allient
Editor for

I am passionate about innovation and entrepreneurship as well as disruptive technologies. https://jonathan-vargas.com