HOME

TheInfoList



OR:

FastAPI is a high-performance
web framework A web framework (WF) or web application framework (WAF) is a software framework that is designed to support the development of web applications including web services, web resources, and web APIs. Web frameworks provide a standard way to build a ...
for building
HTTP HTTP (Hypertext Transfer Protocol) is an application layer protocol in the Internet protocol suite model for distributed, collaborative, hypermedia information systems. HTTP is the foundation of data communication for the World Wide Web, wher ...
-based service
API An application programming interface (API) is a connection between computers or between computer programs. It is a type of software interface, offering a service to other pieces of software. A document or standard that describes how to build ...
s in
Python Python may refer to: Snakes * Pythonidae, a family of nonvenomous snakes found in Africa, Asia, and Australia ** ''Python'' (genus), a genus of Pythonidae found in Africa and Asia * Python (mythology), a mythical serpent Computing * Python (prog ...
3.8+. It uses Pydantic and type hints to
validate Validation may refer to: * Data validation, in computer science, ensuring that data inserted into an application satisfies defined formats and other input criteria * Emotional validation, in interpersonal communication is the Emotion recognition, ...
, serialize and deserialize data. FastAPI also automatically generates OpenAPI documentation for APIs built with it. It was first released in 2018.


Components


Pydantic

Pydantic is a data validation library for Python. While writing code in an IDE, Pydantic provides type hints for schema validation and serialization through type annotations.


Starlette

Starlette is a lightweight ASGI framework/toolkit, to support async functionality in Python.


Uvicorn

Uvicorn is a minimal low-level server/application web server for async frameworks, following th
ASGI specification
Technically, it implements a multi-process model with one main process, which is responsible for managing a pool of worker processes and distributing incoming HTTP requests to them. The number of worker processes is pre-configured, but can also be adjusted up or down at runtime.


OpenAPI Integration

FastAPI automatically generates OpenAPI documentation for APIs. This documentation includes both Swagger UI and ReDoc, which provide interactive API documentation that you can use to explore and test your endpoints in real time. This is particularly useful for developing, testing, and sharing APIs with other developers or users.https://fastapi.tiangolo.com/reference/openapi/docs/


Example

The following code shows a simple web application that displays "
Hello World Hello World may refer to: * "Hello, World!" program, a computer program that outputs or displays the message "Hello, World!" Music * "Hello World!" (composition), song by the Iamus computer * "Hello World" (Tremeloes song), 1969 * "Hello World" ...
!" when visited: # Import FastAPI class from the fastapi package from fastapi import FastAPI # Create an instance of the FastAPI app app = FastAPI() # Define a GET route for the root URL ("/") @app.get("/") async def read_root() -> str: # Return a plain text response return "Hello, World!"


See also

*
Django (web framework) Django ( ; sometimes stylized as django) is a free and open-source software, free and open-source, Python (programming language), Python-based web framework that runs on a web server. It follows the model–template–views (MTV) Architectural ...
*
Flask (web framework) Flask is a micro web framework written in Python. It is classified as a microframework because it does not require particular tools or libraries. It has no database abstraction layer, form validation, or any other components where pre-existing ...
*
Pylons project Pylons Project is an open-source organization that develops a set of web application technologies written in Python. Initially the project was a single web framework called Pylons, but after the merger with the repoze.bfg framework under the new ...
*
Web2py Web2py is an open-source web application framework written in the Python programming language. Web2py allows web developers to program dynamic web content using Python. Web2py is designed to help reduce tedious web development tasks, such a ...
*
Tornado (web server) Tornado is a scalable, non-blocking web server and web application framework written in Python. It was developed for use by FriendFeed; the company was acquired by Facebook in 2009 and Tornado was open-sourced soon after. Performance Tornad ...
* *
REST REST (Representational State Transfer) is a software architectural style that was created to describe the design and guide the development of the architecture for the World Wide Web. REST defines a set of constraints for how the architecture of ...
*
Python (programming language) Python is a high-level programming language, high-level, general-purpose programming language. Its design philosophy emphasizes code readability with the use of significant indentation. Python is type system#DYNAMIC, dynamically type-checked a ...


External links

* *


References

2018 software Python (programming language) web frameworks Software using the MIT license Web frameworks {{web-software-stub