The goal of this blog is to explore the API development in python and try to compare the features on different Parameters.FastAPI and Flask are both such python tools used for creating APIs with their own uniqueness .Django is another famous Web framework widely used in Python Community , but here we are not considering it.Since It is used for monolithic architecture and it is does not support APIs ,however Django-rest is update by Django community for RESTful APIs but still limited use of NoSQL Databases with Django, keeping it out of discussion.
FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.6+ based on standard Python type hints. It is built on top of Starlette, Pydantic, OpenApi and Uvicorn.
- Under the hood, FastAPI uses Pydantic for data validation and Starlette for tooling, making it blazing fast compared to Flask, giving comparable performance to high-speed web APIs in Node or Go.
- Starlette + Uvicorn offers async capability, something that Flask lacks.
- With Pydantic along with type hints, you get a nice editor experience with autocompletion. You also get data validation, serialization and deserialization (for building an API), and automatic documentation (via JSON Schema and OpenAPI).
It is a Python micro web framework.Flask is extremely lightweight.It easy to get started with building a basic application to complex back-end APIs.It is used by Netflix, Reddit,and many more.
- Basic foundation API is nicely shaped and coherent.
- Flask documentation is comprehensive, full of examples and well structured. You can even try out some sample application to really get a feel of Flask.
- It is super easy to deploy Flask in production (Flask is 100% WSGI 1.0 compliant”)