Jump to content

FastAPI

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 174.26.245.52 (talk) at 02:17, 10 December 2023 (Features: referenced additional sources per "This article relies excessively on references to primary sources.". Addressed issue of "The topic of this article may not meet Wikipedia's notability guidelines for products and services" by comparing to other options and where it fits in.). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
FastAPI
Developer(s)Sebastián Ramírez
Initial releaseDecember 5, 2018; 6 years ago (2018-12-05)[1]
Stable release
0.115.13[2] Edit this on Wikidata / 17 June 2025; 25 days ago (17 June 2025)
Repositorygithub.com/tiangolo/fastapi
Written inPython
TypeWeb framework
LicenseMIT
Websitefastapi.tiangolo.com

FastAPI is a modern web framework for building RESTful APIs in Python. It was first released in 2018 and has since quickly gained popularity among developers due to its ease of use, speed and robustness.

FastAPI is based on Pydantic and uses type hints to validate, serialize and deserialize data. It also automatically generates OpenAPI documentation for APIs built with it.[3]

FastAPI fully supports asynchronous programming and can run on Gunicorn and ASGI servers such as Uvicorn and Hypercorn,[4] making it a good choice for production environments. To improve developer-friendliness, editor support was considered since the project's earliest days.[5]

Components

Pydantic

Pydantic is a data validation library for Python. Since the type validation logic is written in Rust programming language, Pydantic is among the fastest data validation libraries for Python. While writing code in an IDE, Pydantic provides type hints for schema validation and serialization through type annotations.[6]

Starlette

Starlette is a lightweight ASGI framework/toolkit, to support async functionality in Python.[7] Starlette has shown great performance by independent benchmarks, which is inherited by FastAPI.[8]

Uvicorn

Uvicorn is a minimal low-level server/application web server for async frameworks, following the ASGI specification.

Features

  • High performance
  • Type hints
  • Data validation
  • Automatic documentation based on OpenAPI standards
  • Dependency injection

Alternatives

Among Python web frameworks, FastAPI is one of the more popular options, competing primarily with Flask and Django, which are also very popular. FastAPI sits somewhere in between these two options, with more out of the box functionality and a steeper learning curve than Flask, but with less functionality and being easier to learn than Django[9] . FastAPI, as the name implies, aims to be used in cases where you need a high performance web API, while both Flask and Django have a broader scope. A comprehensive list of Python web frameworks is available on the python.org wiki[10], where Django is referred to as a "popular full-stack framework" while both FastAPI and Flask are listed as "popular non full-stack frameworks".

Adoption and real-world usage

FastAPI was the third most loved web framework in Stack Overflow 2021 Developer Survey.[11]

Large companies like Uber and Netflix use it to develop some of their applications.[12][13]

Example

The following code shows a simple web application that displays "Hello World!" when visited:

from fastapi import FastAPI

app = FastAPI()

@app.get("/")
def read_root():
    return "Hello World!"

See also

References

  1. ^ "fastapi repo". GitHub. 2018-12-05.
  2. ^ "Release 0.115.13". 17 June 2025. Retrieved 18 June 2025.
  3. ^ Lubanovic, Bill (2019-11-06). Introducing Python: Modern Computing in Simple Packages (2nd ed.). O'Reilly Media, Inc. pp. 397, 418. ISBN 9781492051367.
  4. ^ Philipp Kats; David Katz (2019-08-30). Learn Python by Building Data Science Applications. Packt Publishing Ltd. pp. 435, 365. ISBN 9781789535365.
  5. ^ "History, Design and Future - FastAPI". Retrieved 4 November 2020.
  6. ^ "Why use Pydantic - Pydantic". docs.pydantic.dev. Retrieved 2023-09-21.
  7. ^ "Starlette". www.starlette.io. Retrieved 2023-09-21.
  8. ^ "TechEmpower Web Framework Performance Comparison". www.techempower.com. Retrieved 2023-09-21.
  9. ^ "FastAPI Python Framework". ioflood.com. Retrieved 2023-12-09.
  10. ^ "Python Web Frameworks". wiki.python.org. Retrieved 2023-12-09.
  11. ^ "Stack Overflow Developer Survey 2021". Stack Overflow. Retrieved 2021-08-25.
  12. ^ "Ludwig v0.2 Adds New Features and Other Improvements to its Deep Learning Toolbox". Uber Engineering. 2019-07-24. Retrieved 4 November 2020.
  13. ^ "Introducing Dispatch". Netflix Technology Blog. 2020-02-25. Retrieved 4 November 2020.