fastapi 0.119.1


pip install fastapi

  Latest version

Released: Oct 20, 2025


Meta
Author: Sebastián Ramírez
Requires Python: >=3.8

Classifiers

Intended Audience
  • Developers

Operating System
  • OS Independent

Programming Language
  • Python :: 3 :: Only
  • Python :: 3.8
  • Python :: 3.9
  • Python :: 3.10
  • Python :: 3.11
  • Python :: 3.12
  • Python :: 3.13
  • Python :: 3.14

Topic
  • Internet :: WWW/HTTP :: HTTP Servers
  • Internet :: WWW/HTTP

Typing
  • Typed

Development Status
  • 4 - Beta

Environment
  • Web Environment

Framework
  • AsyncIO
  • FastAPI
  • Pydantic
  • Pydantic :: 1
  • Pydantic :: 2

License
  • OSI Approved :: MIT License

FastAPI

FastAPI framework, high performance, easy to learn, fast to code, ready for production

Test Coverage Package version Supported Python versions


Documentation: https://fastapi.tiangolo.com

Source Code: https://github.com/fastapi/fastapi


FastAPI is a modern, fast (high-performance), web framework for building APIs with Python based on standard Python type hints.

The key features are:

  • Fast: Very high performance, on par with NodeJS and Go (thanks to Starlette and Pydantic). One of the fastest Python frameworks available.
  • Fast to code: Increase the speed to develop features by about 200% to 300%. *
  • Fewer bugs: Reduce about 40% of human (developer) induced errors. *
  • Intuitive: Great editor support. Completion everywhere. Less time debugging.
  • Easy: Designed to be easy to use and learn. Less time reading docs.
  • Short: Minimize code duplication. Multiple features from each parameter declaration. Fewer bugs.
  • Robust: Get production-ready code. With automatic interactive documentation.
  • Standards-based: Based on (and fully compatible with) the open standards for APIs: OpenAPI (previously known as Swagger) and JSON Schema.

* estimation based on tests on an internal development team, building production applications.

Sponsors

Other sponsors

Opinions

"[...] I'm using FastAPI a ton these days. [...] I'm actually planning to use it for all of my team's ML services at Microsoft. Some of them are getting integrated into the core Windows product and some Office products."

Kabir Khan - Microsoft (ref)

"We adopted the FastAPI library to spawn a REST server that can be queried to obtain predictions. [for Ludwig]"

Piero Molino, Yaroslav Dudin, and Sai Sumanth Miryala - Uber (ref)

"Netflix is pleased to announce the open-source release of our crisis management orchestration framework: Dispatch! [built with FastAPI]"

Kevin Glisson, Marc Vilanova, Forest Monsen - Netflix (ref)

"I’m over the moon excited about FastAPI. It’s so fun!"

Brian Okken - Python Bytes podcast host (ref)

"Honestly, what you've built looks super solid and polished. In many ways, it's what I wanted Hug to be - it's really inspiring to see someone build that."

Timothy Crosley - Hug creator (ref)

"If you're looking to learn one modern framework for building REST APIs, check out FastAPI [...] It's fast, easy to use and easy to learn [...]"

"We've switched over to FastAPI for our APIs [...] I think you'll like it [...]"

Ines Montani - Matthew Honnibal - Explosion AI founders - spaCy creators (ref) - (ref)

"If anyone is looking to build a production Python API, I would highly recommend FastAPI. It is beautifully designed, simple to use and highly scalable, it has become a key component in our API first development strategy and is driving many automations and services such as our Virtual TAC Engineer."

Deon Pillsbury - Cisco (ref)

Typer, the FastAPI of CLIs

If you are building a CLI app to be used in the terminal instead of a web API, check out Typer.

Typer is FastAPI's little sibling. And it's intended to be the FastAPI of CLIs. ⌨️ 🚀

Requirements

FastAPI stands on the shoulders of giants:

Installation

Create and activate a virtual environment and then install FastAPI:

$ pip install "fastapi[standard]"

---> 100%

Note: Make sure you put "fastapi[standard]" in quotes to ensure it works in all terminals.

Example

Create it

Create a file main.py with:

from typing import Union

from fastapi import FastAPI

app = FastAPI()


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


@app.get("/items/{item_id}")
def read_item(item_id: int, q: Union[str, None] = None):
    return {"item_id": item_id, "q": q}
Or use async def...

If your code uses async / await, use async def:

from typing import Union

from fastapi import FastAPI

app = FastAPI()


@app.get("/")
async def read_root():
    return {"Hello": "World"}


@app.get("/items/{item_id}")
async def read_item(item_id: int, q: Union[str, None] = None):
    return {"item_id": item_id, "q": q}

Note:

If you don't know, check the "In a hurry?" section about async and await in the docs.

Run it

Run the server with:

$ fastapi dev main.py

 ╭────────── FastAPI CLI - Development mode ───────────╮
 │                                                     │
 │  Serving at: http://127.0.0.1:8000                  │
 │                                                     │
 │  API docs: http://127.0.0.1:8000/docs               │
 │                                                     │
 │  Running in development mode, for production use:   │
 │                                                     │
 │  fastapi run                                        │
 │                                                     │
 ╰─────────────────────────────────────────────────────╯

INFO:     Will watch for changes in these directories: ['/home/user/code/awesomeapp']
INFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
INFO:     Started reloader process [2248755] using WatchFiles
INFO:     Started server process [2248757]
INFO:     Waiting for application startup.
INFO:     Application startup complete.
About the command fastapi dev main.py...

The command fastapi dev reads your main.py file, detects the FastAPI app in it, and starts a server using Uvicorn.

By default, fastapi dev will start with auto-reload enabled for local development.

You can read more about it in the FastAPI CLI docs.

Check it

Open your browser at http://127.0.0.1:8000/items/5?q=somequery.

You will see the JSON response as:

{"item_id": 5, "q": "somequery"}

You already created an API that:

  • Receives HTTP requests in the paths / and /items/{item_id}.
  • Both paths take GET operations (also known as HTTP methods).
  • The path /items/{item_id} has a path parameter item_id that should be an int.
  • The path /items/{item_id} has an optional str query parameter q.

Interactive API docs

Now go to http://127.0.0.1:8000/docs.

You will see the automatic interactive API documentation (provided by Swagger UI):

Swagger UI

Alternative API docs

And now, go to http://127.0.0.1:8000/redoc.

You will see the alternative automatic documentation (provided by ReDoc):

ReDoc

Example upgrade

Now modify the file main.py to receive a body from a PUT request.

Declare the body using standard Python types, thanks to Pydantic.

from typing import Union

from fastapi import FastAPI
from pydantic import BaseModel

app = FastAPI()


class Item(BaseModel):
    name: str
    price: float
    is_offer: Union[bool, None] = None


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


@app.get("/items/{item_id}")
def read_item(item_id: int, q: Union[str, None] = None):
    return {"item_id": item_id, "q": q}


@app.put("/items/{item_id}")
def update_item(item_id: int, item: Item):
    return {"item_name": item.name, "item_id": item_id}

The fastapi dev server should reload automatically.

Interactive API docs upgrade

Now go to http://127.0.0.1:8000/docs.

  • The interactive API documentation will be automatically updated, including the new body:

Swagger UI

  • Click on the button "Try it out", it allows you to fill the parameters and directly interact with the API:

Swagger UI interaction

  • Then click on the "Execute" button, the user interface will communicate with your API, send the parameters, get the results and show them on the screen:

Swagger UI interaction

Alternative API docs upgrade

And now, go to http://127.0.0.1:8000/redoc.

  • The alternative documentation will also reflect the new query parameter and body:

ReDoc

Recap

In summary, you declare once the types of parameters, body, etc. as function parameters.

You do that with standard modern Python types.

You don't have to learn a new syntax, the methods or classes of a specific library, etc.

Just standard Python.

For example, for an int:

item_id: int

or for a more complex Item model:

item: Item

...and with that single declaration you get:

  • Editor support, including:
    • Completion.
    • Type checks.
  • Validation of data:
    • Automatic and clear errors when the data is invalid.
    • Validation even for deeply nested JSON objects.
  • Conversion of input data: coming from the network to Python data and types. Reading from:
    • JSON.
    • Path parameters.
    • Query parameters.
    • Cookies.
    • Headers.
    • Forms.
    • Files.
  • Conversion of output data: converting from Python data and types to network data (as JSON):
    • Convert Python types (str, int, float, bool, list, etc).
    • datetime objects.
    • UUID objects.
    • Database models.
    • ...and many more.
  • Automatic interactive API documentation, including 2 alternative user interfaces:
    • Swagger UI.
    • ReDoc.

Coming back to the previous code example, FastAPI will:

  • Validate that there is an item_id in the path for GET and PUT requests.
  • Validate that the item_id is of type int for GET and PUT requests.
    • If it is not, the client will see a useful, clear error.
  • Check if there is an optional query parameter named q (as in http://127.0.0.1:8000/items/foo?q=somequery) for GET requests.
    • As the q parameter is declared with = None, it is optional.
    • Without the None it would be required (as is the body in the case with PUT).
  • For PUT requests to /items/{item_id}, read the body as JSON:
    • Check that it has a required attribute name that should be a str.
    • Check that it has a required attribute price that has to be a float.
    • Check that it has an optional attribute is_offer, that should be a bool, if present.
    • All this would also work for deeply nested JSON objects.
  • Convert from and to JSON automatically.
  • Document everything with OpenAPI, that can be used by:
    • Interactive documentation systems.
    • Automatic client code generation systems, for many languages.
  • Provide 2 interactive documentation web interfaces directly.

We just scratched the surface, but you already get the idea of how it all works.

Try changing the line with:

    return {"item_name": item.name, "item_id": item_id}

...from:

        ... "item_name": item.name ...

...to:

        ... "item_price": item.price ...

...and see how your editor will auto-complete the attributes and know their types:

editor support

For a more complete example including more features, see the Tutorial - User Guide.

Spoiler alert: the tutorial - user guide includes:

  • Declaration of parameters from other different places as: headers, cookies, form fields and files.
  • How to set validation constraints as maximum_length or regex.
  • A very powerful and easy to use Dependency Injection system.
  • Security and authentication, including support for OAuth2 with JWT tokens and HTTP Basic auth.
  • More advanced (but equally easy) techniques for declaring deeply nested JSON models (thanks to Pydantic).
  • GraphQL integration with Strawberry and other libraries.
  • Many extra features (thanks to Starlette) as:
    • WebSockets
    • extremely easy tests based on HTTPX and pytest
    • CORS
    • Cookie Sessions
    • ...and more.

Performance

Independent TechEmpower benchmarks show FastAPI applications running under Uvicorn as one of the fastest Python frameworks available, only below Starlette and Uvicorn themselves (used internally by FastAPI). (*)

To understand more about it, see the section Benchmarks.

Dependencies

FastAPI depends on Pydantic and Starlette.

standard Dependencies

When you install FastAPI with pip install "fastapi[standard]" it comes with the standard group of optional dependencies:

Used by Pydantic:

Used by Starlette:

  • httpx - Required if you want to use the TestClient.
  • jinja2 - Required if you want to use the default template configuration.
  • python-multipart - Required if you want to support form "parsing", with request.form().

Used by FastAPI:

  • uvicorn - for the server that loads and serves your application. This includes uvicorn[standard], which includes some dependencies (e.g. uvloop) needed for high performance serving.
  • fastapi-cli[standard] - to provide the fastapi command.
    • This includes fastapi-cloud-cli, which allows you to deploy your FastAPI application to FastAPI Cloud.

Without standard Dependencies

If you don't want to include the standard optional dependencies, you can install with pip install fastapi instead of pip install "fastapi[standard]".

Without fastapi-cloud-cli

If you want to install FastAPI with the standard dependencies but without the fastapi-cloud-cli, you can install with pip install "fastapi[standard-no-fastapi-cloud-cli]".

Additional Optional Dependencies

There are some additional dependencies you might want to install.

Additional optional Pydantic dependencies:

Additional optional FastAPI dependencies:

  • orjson - Required if you want to use ORJSONResponse.
  • ujson - Required if you want to use UJSONResponse.

License

This project is licensed under the terms of the MIT license.

0.119.1 Oct 20, 2025
0.119.0 Oct 11, 2025
0.118.3 Oct 10, 2025
0.118.2 Oct 08, 2025
0.118.1 Oct 08, 2025
0.118.0 Sep 29, 2025
0.117.1 Sep 20, 2025
0.117.0 Sep 20, 2025
0.116.2 Sep 16, 2025
0.116.1 Jul 11, 2025
0.116.0 Jul 07, 2025
0.115.14 Jun 26, 2025
0.115.13 Jun 17, 2025
0.115.12 Mar 23, 2025
0.115.11 Mar 01, 2025
0.115.10 Feb 28, 2025
0.115.9 Feb 27, 2025
0.115.8 Jan 30, 2025
0.115.7 Jan 22, 2025
0.115.6 Dec 03, 2024
0.115.5 Nov 12, 2024
0.115.4 Oct 27, 2024
0.115.3 Oct 22, 2024
0.115.2 Oct 12, 2024
0.115.1 Oct 12, 2024
0.115.0 Sep 17, 2024
0.114.2 Sep 13, 2024
0.114.1 Sep 11, 2024
0.114.0 Sep 06, 2024
0.113.0 Sep 05, 2024
0.112.4 Sep 05, 2024
0.112.3 Sep 05, 2024
0.112.2 Aug 24, 2024
0.112.1 Aug 15, 2024
0.112.0 Aug 02, 2024
0.111.1 Jul 14, 2024
0.111.0 May 03, 2024
0.111.0.dev1 Apr 30, 2024
0.110.3 Apr 30, 2024
0.110.3.dev2 Apr 29, 2024
0.110.3.dev1 Apr 29, 2024
0.110.2 Apr 19, 2024
0.110.1 Apr 02, 2024
0.110.0 Feb 24, 2024
0.109.2 Feb 04, 2024
0.109.1 Feb 03, 2024
0.109.0 Jan 11, 2024
0.108.0 Dec 26, 2023
0.107.0 Dec 26, 2023
0.106.0 Dec 25, 2023
0.105.0 Dec 12, 2023
0.104.1 Oct 30, 2023
0.104.0 Oct 18, 2023
0.103.2 Sep 28, 2023
0.103.1 Sep 02, 2023
0.103.0 Aug 26, 2023
0.102.0 Aug 25, 2023
0.101.1 Aug 14, 2023
0.101.0 Aug 04, 2023
0.100.1 Jul 27, 2023
0.100.0 Jul 07, 2023
0.100.0b3 Jul 05, 2023
0.100.0b2 Jun 30, 2023
0.100.0b1 Jun 20, 2023
0.99.1 Jul 02, 2023
0.99.0 Jun 30, 2023
0.98.0 Jun 22, 2023
0.97.0 Jun 11, 2023
0.96.1 Jun 10, 2023
0.96.0 Jun 03, 2023
0.95.2 May 16, 2023
0.95.1 Apr 13, 2023
0.95.0 Mar 18, 2023
0.94.1 Mar 14, 2023
0.94.0 Mar 10, 2023
0.93.0 Mar 07, 2023
0.92.0 Feb 14, 2023
0.91.0 Feb 10, 2023
0.90.1 Feb 09, 2023
0.90.0 Feb 08, 2023
0.89.1 Jan 10, 2023
0.89.0 Jan 07, 2023
0.88.0 Nov 27, 2022
0.87.0 Nov 13, 2022
0.86.0 Nov 03, 2022
0.85.2 Oct 31, 2022
0.85.1 Oct 14, 2022
0.85.0 Sep 15, 2022
0.84.0 Sep 14, 2022
0.83.0 Sep 11, 2022
0.82.0 Sep 04, 2022
0.81.0 Aug 26, 2022
0.80.0 Aug 23, 2022
0.79.1 Aug 18, 2022
0.79.0 Jul 14, 2022
0.78.0 May 14, 2022
0.77.1 May 10, 2022
0.77.0 May 10, 2022
0.76.0 May 05, 2022
0.75.2 Apr 17, 2022
0.75.1 Apr 01, 2022
0.75.0 Mar 04, 2022
0.74.1 Feb 21, 2022
0.74.0 Feb 17, 2022
0.73.0 Jan 23, 2022
0.72.0 Jan 16, 2022
0.71.0 Jan 07, 2022
0.70.1 Dec 12, 2021
0.70.0 Oct 07, 2021
0.69.0 Oct 07, 2021
0.68.2 Oct 05, 2021
0.68.1 Aug 24, 2021
0.68.0 Jul 29, 2021
0.67.0 Jul 21, 2021
0.66.1 Jul 19, 2021
0.66.0 Jul 04, 2021
0.65.3 Jul 03, 2021
0.65.2 Jun 09, 2021
0.65.1 May 11, 2021
0.65.0 May 10, 2021
0.64.0 May 07, 2021
0.63.0 Dec 20, 2020
0.62.0 Nov 29, 2020
0.61.2 Nov 05, 2020
0.61.1 Aug 29, 2020
0.61.0 Aug 09, 2020
0.60.2 Aug 08, 2020
0.60.1 Jul 22, 2020
0.60.0 Jul 20, 2020
0.59.0 Jul 10, 2020
0.58.1 Jun 28, 2020
0.58.0 Jun 15, 2020
0.57.0 Jun 13, 2020
0.56.1 Jun 12, 2020
0.56.0 Jun 11, 2020
0.55.1 May 23, 2020
0.55.0 May 23, 2020
0.54.2 May 16, 2020
0.54.1 Apr 08, 2020
0.54.0 Apr 05, 2020
0.53.2 Mar 30, 2020
0.53.1 Mar 29, 2020
0.53.0 Mar 27, 2020
0.52.0 Mar 01, 2020
0.51.0 Mar 01, 2020
0.50.0 Feb 29, 2020
0.49.2 Feb 29, 2020
0.49.1 Feb 28, 2020
0.49.0 Feb 16, 2020
0.48.0 Feb 04, 2020
0.47.1 Jan 18, 2020
0.47.0 Jan 18, 2020
0.46.0 Jan 08, 2020
0.45.0 Dec 11, 2019
0.44.1 Dec 04, 2019
0.44.0 Nov 27, 2019
0.43.0 Nov 24, 2019
0.42.0 Oct 09, 2019
0.41.0 Oct 07, 2019
0.40.0 Oct 04, 2019
0.39.0 Sep 29, 2019
0.38.1 Sep 01, 2019
0.38.0 Aug 31, 2019
0.37.0 Aug 31, 2019
0.36.0 Aug 26, 2019
0.35.0 Aug 08, 2019
0.34.0 Aug 06, 2019
0.33.0 Jul 13, 2019
0.32.0 Jul 12, 2019
0.31.0 Jun 28, 2019
0.30.1 Jun 28, 2019
0.30.0 Jun 20, 2019
0.29.1 Jun 13, 2019
0.29.0 Jun 06, 2019
0.28.0 Jun 05, 2019
0.27.2 Jun 03, 2019
0.27.1 Jun 03, 2019
0.27.0 May 30, 2019
0.26.0 May 29, 2019
0.25.0 May 27, 2019
0.24.0 May 24, 2019
0.23.0 May 21, 2019
0.22.0 May 16, 2019
0.21.0 May 15, 2019
0.20.1 May 11, 2019
0.20.0 Apr 27, 2019
0.19.0 Apr 26, 2019
0.18.0 Apr 22, 2019
0.17.0 Apr 20, 2019
0.16.0 Apr 16, 2019
0.15.0 Apr 14, 2019
0.14.0 Apr 12, 2019
0.13.0 Apr 09, 2019
0.12.1 Apr 05, 2019
0.12.0 Apr 05, 2019
0.11.0 Apr 03, 2019
0.10.2 Mar 29, 2019
0.10.1 Mar 25, 2019
0.10.0 Mar 24, 2019
0.9.1 Mar 22, 2019
0.9.0 Mar 22, 2019
0.8.0 Mar 16, 2019
0.7.1 Mar 04, 2019
0.7.0 Mar 03, 2019
0.6.4 Mar 02, 2019
0.6.3 Feb 23, 2019
0.6.2 Feb 23, 2019
0.6.1 Feb 20, 2019
0.6.0 Feb 19, 2019
0.5.1 Feb 18, 2019
0.5.0 Feb 16, 2019
0.4.0 Feb 14, 2019
0.3.0 Feb 12, 2019
0.2.1 Feb 12, 2019
0.2.0 Feb 08, 2019
0.1.19 Feb 01, 2019
0.1.18 Jan 23, 2019
0.1.17 Jan 05, 2019
0.1.16 Dec 30, 2018
0.1.15 Dec 28, 2018
0.1.14 Dec 24, 2018
0.1.13 Dec 24, 2018
0.1.12 Dec 21, 2018
0.1.11 Dec 21, 2018
0.1.10 Dec 10, 2018
0.1.9 Dec 10, 2018
0.1.8 Dec 10, 2018
0.1.7 Dec 10, 2018
0.1.6 Dec 10, 2018
0.1.5 Dec 10, 2018
0.1.4 Dec 10, 2018
0.1.3 Dec 10, 2018
0.1.2 Dec 10, 2018
0.1.0 Dec 08, 2018

Wheel compatibility matrix

Platform Python 3
any

Files in release

Extras:
Dependencies:
starlette (<0.49.0,>=0.40.0)
pydantic (!=1.8,!=1.8.1,!=2.0.0,!=2.0.1,!=2.1.0,<3.0.0,>=1.7.4)
typing-extensions (>=4.8.0)