FastAPI is a modern, fast (high-performance), web framework for building APIs with Python based on standard Python type hints.
# Overview
The key features are:
FastAPI is a modern, fast (high‑performance) web framework for building APIs with Python 3.8+ based on standard Python type hints. It combines the speed of **Node.js** and **Go** with the developer friendliness of **Python**, delivering:
* **Fast**: Very high performance, on par with **NodeJS** and **Go** (thanks to Starlette and Pydantic). [One of the fastest Python frameworks available](#performance).
* **Performance** – on par with the fastest Python frameworks because it is built on **Starlette** for the web parts and **Pydantic** for the data parts.
* **Fast to code**: Increase the speed to develop features by about 200% to 300%. *
* **Fast to code** – increase development speed by 200 %–300 % thanks to automatic request validation, serialization, interactive API docs, and editor autocompletion.
* **Fewer bugs**: Reduce about 40% of human (developer) induced errors. *
* **Reduced bugs** – data validation and type checking catch many errors at runtime, lowering the chance of human‑introduced bugs.
* **Intuitive**: Great editor support. <dfntitle="also known as auto-complete, autocompletion, IntelliSense">Completion</dfn> everywhere. Less time debugging.
* **Intuitive** – editors provide instant completion and type checking for request bodies, query parameters, headers, and more.
* **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: <ahref="https://github.com/OAI/OpenAPI-Specification"class="external-link"target="_blank">OpenAPI</a> (previously known as Swagger) and <ahref="https://json-schema.org/"class="external-link"target="_blank">JSON Schema</a>.
<small>* estimation based on tests conducted by an internal development team, building production applications.</small>
# Installation
## Sponsors
FastAPI is released on PyPI and can be installed with **pip**. It has no external runtime dependencies besides **uvicorn** (or another ASGI server) for development and production.
<!-- sponsors -->
```bash
### Keystone Sponsor
pip install "fastapi[all]" # includes optional dependencies such as python‑multipart, email‑validator, jinja2
# Or, if you only need the core framework:
<ahref="https://fastapicloud.com"target="_blank"title="FastAPI Cloud. By the same team behind FastAPI. You code. We Cloud."><imgsrc="https://fastapi.tiangolo.com/img/sponsors/fastapicloud.png"></a>
<ahref="https://github.com/scalar/scalar/?utm_source=fastapi&utm_medium=website&utm_campaign=main-badge"target="_blank"title="Scalar: Beautiful Open-Source API References from Swagger/OpenAPI files"><imgsrc="https://fastapi.tiangolo.com/img/sponsors/scalar.svg"></a>
<ahref="https://www.propelauth.com/?utm_source=fastapi&utm_campaign=1223&utm_medium=mainbadge"target="_blank"title="Auth, user management and more for your B2B product"><imgsrc="https://fastapi.tiangolo.com/img/sponsors/propelauth.png"></a>
<ahref="https://zuplo.link/fastapi-gh"target="_blank"title="Zuplo: Deploy, Secure, Document, and Monetize your FastAPI"><imgsrc="https://fastapi.tiangolo.com/img/sponsors/zuplo.png"></a>
<ahref="https://liblab.com?utm_source=fastapi"target="_blank"title="liblab - Generate SDKs from FastAPI"><imgsrc="https://fastapi.tiangolo.com/img/sponsors/liblab.png"></a>
<ahref="https://docs.render.com/deploy-fastapi?utm_source=deploydoc&utm_medium=referral&utm_campaign=fastapi"target="_blank"title="Deploy & scale any full-stack web app on Render. Focus on building apps, not infra."><imgsrc="https://fastapi.tiangolo.com/img/sponsors/render.svg"></a>
<ahref="https://www.coderabbit.ai/?utm_source=fastapi&utm_medium=badge&utm_campaign=fastapi"target="_blank"title="Cut Code Review Time & Bugs in Half with CodeRabbit"><imgsrc="https://fastapi.tiangolo.com/img/sponsors/coderabbit.png"></a>
<ahref="https://subtotal.com/?utm_source=fastapi&utm_medium=sponsorship&utm_campaign=open-source"target="_blank"title="The Gold Standard in Retail Account Linking"><imgsrc="https://fastapi.tiangolo.com/img/sponsors/subtotal.svg"></a>
<ahref="https://docs.railway.com/guides/fastapi?utm_medium=integration&utm_source=docs&utm_campaign=fastapi"target="_blank"title="Deploy enterprise applications at startup speed"><imgsrc="https://fastapi.tiangolo.com/img/sponsors/railway.png"></a>
<ahref="https://serpapi.com/?utm_source=fastapi_website"target="_blank"title="SerpApi: Web Search API"><imgsrc="https://fastapi.tiangolo.com/img/sponsors/serpapi.png"></a>
<ahref="https://www.greptile.com/?utm_source=fastapi&utm_medium=sponsorship&utm_campaign=fastapi_sponsor_page"target="_blank"title="Greptile: The AI Code Reviewer"><imgsrc="https://fastapi.tiangolo.com/img/sponsors/greptile.png"></a>
<ahref="https://databento.com/?utm_source=fastapi&utm_medium=sponsor&utm_content=display"target="_blank"title="Pay as you go for market data"><imgsrc="https://fastapi.tiangolo.com/img/sponsors/databento.svg"></a>
<ahref="https://speakeasy.com/editor?utm_source=fastapi+repo&utm_medium=github+sponsorship"target="_blank"title="SDKs for your API | Speakeasy"><imgsrc="https://fastapi.tiangolo.com/img/sponsors/speakeasy.png"></a>
<ahref="https://www.svix.com/"target="_blank"title="Svix - Webhooks as a service"><imgsrc="https://fastapi.tiangolo.com/img/sponsors/svix.svg"></a>
<ahref="https://www.permit.io/blog/implement-authorization-in-fastapi?utm_source=github&utm_medium=referral&utm_campaign=fastapi"target="_blank"title="Fine-Grained Authorization for FastAPI"><imgsrc="https://fastapi.tiangolo.com/img/sponsors/permit.png"></a>
<ahref="https://www.interviewpal.com/?utm_source=fastapi&utm_medium=open-source&utm_campaign=dev-hiring"target="_blank"title="InterviewPal - AI Interview Coach for Engineers and Devs"><imgsrc="https://fastapi.tiangolo.com/img/sponsors/interviewpal.png"></a>
<ahref="https://dribia.com/en/"target="_blank"title="Dribia - Data Science within your reach"><imgsrc="https://fastapi.tiangolo.com/img/sponsors/dribia.png"></a>
"_[...] 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._"
"_We adopted the **FastAPI** library to spawn a **REST** server that can be queried to obtain **predictions**. [for Ludwig]_"
<divstyle="text-align: right; margin-right: 10%;">Piero Molino, Yaroslav Dudin, and Sai Sumanth Miryala - <strong>Uber</strong><ahref="https://eng.uber.com/ludwig-v0-2/"target="_blank"><small>(ref)</small></a></div>
---
"_**Netflix** is pleased to announce the open-source release of our **crisis management** orchestration framework: **Dispatch**! [built with **FastAPI**]_"
"_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._"
"_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 [...]_"
"_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._"
There's a <ahref="https://www.youtube.com/watch?v=mpR8ngthqiE"class="external-link"target="_blank">FastAPI mini documentary</a> released at the end of 2025, you can watch it online:
<ahref="https://www.youtube.com/watch?v=mpR8ngthqiE"target="_blank"><imgsrc="https://fastapi.tiangolo.com/img/fastapi-documentary.jpg"alt="FastAPI Mini Documentary"></a>
If you are building a <abbrtitle="Command Line Interface">CLI</abbr> app to be used in the terminal instead of a web API, check out <ahref="https://typer.tiangolo.com/"class="external-link"target="_blank">**Typer**</a>.
**Typer** is FastAPI's little sibling. And it's intended to be the **FastAPI of CLIs**. ⌨️ 🚀
## Requirements
FastAPI stands on the shoulders of giants:
* <ahref="https://www.starlette.dev/"class="external-link"target="_blank">Starlette</a> for the web parts.
* <ahref="https://docs.pydantic.dev/"class="external-link"target="_blank">Pydantic</a> for the data parts.
## Installation
Create and activate a <ahref="https://fastapi.tiangolo.com/virtual-environments/"class="external-link"target="_blank">virtual environment</a> and then install FastAPI:
<divclass="termy">
```console
$ pip install "fastapi[standard]"
---> 100%
```
</div>
**Note**: Make sure you put `"fastapi[standard]"` in quotes to ensure it works in all terminals.
If you don't know, check the _"In a hurry?"_ section about <ahref="https://fastapi.tiangolo.com/async/#in-a-hurry"target="_blank">`async` and `await` in the docs</a>.
</details>
### Run it
Run the server with:
<divclass="termy">
```console
$ 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: │
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.
```
</div>
<detailsmarkdown="1">
<summary>About the command <code>fastapi dev main.py</code>...</summary>
The command `fastapi dev` reads your `main.py` file, detects the **FastAPI** app in it, and starts a server using <ahref="https://www.uvicorn.dev"class="external-link"target="_blank">Uvicorn</a>.
By default, `fastapi dev` will start with auto-reload enabled for local development.
You can read more about it in the <ahref="https://fastapi.tiangolo.com/fastapi-cli/"target="_blank">FastAPI CLI docs</a>.
</details>
### Check it
Open your browser at <ahref="http://127.0.0.1:8000/items/5?q=somequery"class="external-link"target="_blank">http://127.0.0.1:8000/items/5?q=somequery</a>.
You will see the JSON response as:
```JSON
{"item_id": 5, "q": "somequery"}
```
```
You already created an API that:
> **Note**: FastAPI requires Python **3.8** or newer.
* Receives HTTP requests in the _paths_`/` and `/items/{item_id}`.
# Quick start
* Both _paths_ take `GET`<em>operations</em> (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
Below is a minimal example that demonstrates the core concepts:
Now go to <ahref="http://127.0.0.1:8000/docs"class="external-link"target="_blank">http://127.0.0.1:8000/docs</a>.
```python
You will see the automatic interactive API documentation (provided by <ahref="https://github.com/swagger-api/swagger-ui"class="external-link"target="_blank">Swagger UI</a>):
And now, go to <ahref="http://127.0.0.1:8000/redoc"class="external-link"target="_blank">http://127.0.0.1:8000/redoc</a>.
You will see the alternative automatic documentation (provided by <ahref="https://github.com/Rebilly/ReDoc"class="external-link"target="_blank">ReDoc</a>):
* 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:
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`:
```Python
item_id: int
```
or for a more complex `Item` model:
```Python
item: Item
```
```
...and with that single declaration you get:
Open your browser at <http://127.0.0.1:8000/docs> to see the automatically generated Swagger UI, or at <http://127.0.0.1:8000/redoc> for ReDoc.
* 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.
* <dfntitle="also known as: serialization, parsing, marshalling">Conversion</dfn> of input data: coming from the network to Python data and types. Reading from:
* JSON.
* Path parameters.
* Query parameters.
* Cookies.
* Headers.
* Forms.
* Files.
* <dfntitle="also known as: serialization, parsing, marshalling">Conversion</dfn> of output data: converting from Python data and types to network data (as JSON):
For a more complete example including more features, see the <ahref="https://fastapi.tiangolo.com/tutorial/">Tutorial - User Guide</a>.
Contributions are welcome! Please read our [CONTRIBUTING guide](https://github.com/fastapi/fastapi/blob/master/CONTRIBUTING.md) before submitting a pull request. All contributors are expected to follow the code of conduct and ensure that new code is covered by tests and adheres to the project's style guidelines.
**Spoiler alert**: the tutorial - user guide includes:
# License
* Declaration of **parameters** from other different places as: **headers**, **cookies**, **form fields** and **files**.
FastAPI is licensed under the MIT License. See the `LICENSE` file for the full text.
* How to set **validation constraints** as `maximum_length` or `regex`.
* A very powerful and easy to use **<dfntitle="also known as components, resources, providers, services, injectables">Dependency Injection</dfn>** 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 <ahref="https://strawberry.rocks"class="external-link"target="_blank">Strawberry</a> and other libraries.
* Many extra features (thanks to Starlette) as:
* **WebSockets**
* extremely easy tests based on HTTPX and `pytest`
* **CORS**
* **Cookie Sessions**
* ...and more.
### Deploy your app (optional)
---
You can optionally deploy your FastAPI app to <ahref="https://fastapicloud.com"class="external-link"target="_blank">FastAPI Cloud</a>, go and join the waiting list if you haven't. 🚀
If you already have a **FastAPI Cloud** account (we invited you from the waiting list 😉), you can deploy your application with one command.
Before deploying, make sure you are logged in:
<divclass="termy">
```console
$ fastapi login
You are logged in to FastAPI Cloud 🚀
```
</div>
Then deploy your app:
<divclass="termy">
```console
$ fastapi deploy
Deploying to FastAPI Cloud...
✅ Deployment successful!
🐔 Ready the chicken! Your app is ready at https://myapp.fastapicloud.dev
```
</div>
That's it! Now you can access your app at that URL. ✨
#### About FastAPI Cloud
**<ahref="https://fastapicloud.com"class="external-link"target="_blank">FastAPI Cloud</a>** is built by the same author and team behind **FastAPI**.
It streamlines the process of **building**, **deploying**, and **accessing** an API with minimal effort.
It brings the same **developer experience** of building apps with FastAPI to **deploying** them to the cloud. 🎉
FastAPI Cloud is the primary sponsor and funding provider for the *FastAPI and friends* open source projects. ✨
#### Deploy to other cloud providers
FastAPI is open source and based on standards. You can deploy FastAPI apps to any cloud provider you choose.
Follow your cloud provider's guides to deploy FastAPI apps with them. 🤓
## Performance
Independent TechEmpower benchmarks show **FastAPI** applications running under Uvicorn as <ahref="https://www.techempower.com/benchmarks/#section=test&runid=7464e520-0dc2-473d-bd34-dbdfd7e85911&hw=ph&test=query&l=zijzen-7"class="external-link"target="_blank">one of the fastest Python frameworks available</a>, only below Starlette and Uvicorn themselves (used internally by FastAPI). (*)
To understand more about it, see the section <ahref="https://fastapi.tiangolo.com/benchmarks/"class="internal-link"target="_blank">Benchmarks</a>.
## 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:
* <ahref="https://github.com/JoshData/python-email-validator"target="_blank"><code>email-validator</code></a> - for email validation.
Used by Starlette:
* <ahref="https://www.python-httpx.org"target="_blank"><code>httpx</code></a> - Required if you want to use the `TestClient`.
* <ahref="https://jinja.palletsprojects.com"target="_blank"><code>jinja2</code></a> - Required if you want to use the default template configuration.
* <ahref="https://github.com/Kludex/python-multipart"target="_blank"><code>python-multipart</code></a> - Required if you want to support form <dfntitle="converting the string that comes from an HTTP request into Python data">"parsing"</dfn>, with `request.form()`.
Used by FastAPI:
* <ahref="https://www.uvicorn.dev"target="_blank"><code>uvicorn</code></a> - 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 <ahref="https://fastapicloud.com"class="external-link"target="_blank">FastAPI Cloud</a>.
### 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:
* <ahref="https://docs.pydantic.dev/latest/usage/pydantic_settings/"target="_blank"><code>pydantic-settings</code></a> - for settings management.
* <ahref="https://docs.pydantic.dev/latest/usage/types/extra_types/extra_types/"target="_blank"><code>pydantic-extra-types</code></a> - for extra types to be used with Pydantic.
Additional optional FastAPI dependencies:
* <ahref="https://github.com/ijl/orjson"target="_blank"><code>orjson</code></a> - Required if you want to use `ORJSONResponse`.
* <ahref="https://github.com/esnme/ultrajson"target="_blank"><code>ujson</code></a> - Required if you want to use `UJSONResponse`.
## License
This project is licensed under the terms of the MIT license.
*FastAPI – The modern, fast (high‑performance) web framework for building APIs with Python.*