fastapi
FastAPI framework, high performance, easy to learn, fast to code, ready for production
Science Score: 54.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
6 of 821 committers (0.7%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (14.5%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
FastAPI framework, high performance, easy to learn, fast to code, ready for production
Basic Info
- Host: GitHub
- Owner: fastapi
- License: mit
- Language: Python
- Default Branch: master
- Homepage: https://fastapi.tiangolo.com/
- Size: 26.7 MB
Statistics
- Stars: 88,920
- Watchers: 713
- Forks: 7,793
- Open Issues: 281
- Releases: 208
Topics
Metadata Files
README.md
FastAPI framework, high performance, easy to learn, fast to code, ready for production
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 { #sponsors }
Opinions { #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."
"We adopted the FastAPI library to spawn a REST server that can be queried to obtain predictions. [for Ludwig]"
"Netflix is pleased to announce the open-source release of our crisis management orchestration framework: Dispatch! [built with FastAPI]"
"I’m over the moon excited about FastAPI. It’s so fun!"
"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."
Typer, the FastAPI of CLIs { #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 { #requirements }
FastAPI stands on the shoulders of giants:
Installation { #installation }
Create and activate a virtual environment and then install FastAPI:
Note: Make sure you put "fastapi[standard]" in quotes to ensure it works in all terminals.
Example { #example }
Create it { #create-it }
Create a file main.py with:
```Python from typing import Union
from fastapi import FastAPI
app = FastAPI()
@app.get("/") def read_root(): return {"Hello": "World"}
@app.get("/items/{itemid}") def readitem(itemid: int, q: Union[str, None] = None): return {"itemid": item_id, "q": q} ```
Or use async def...
If your code uses `async` / `await`, use `async def`:
```Python hl_lines="9 14"
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-it }
Run the server with:
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 { #check-it }
Open your browser at http://127.0.0.1:8000/items/5?q=somequery.
You will see the JSON response as:
JSON
{"item_id": 5, "q": "somequery"}
You already created an API that:
- Receives HTTP requests in the paths
/and/items/{item_id}. - Both paths take
GEToperations (also known as HTTP methods). - The path
/items/{item_id}has a path parameteritem_idthat should be anint. - The path
/items/{item_id}has an optionalstrquery parameterq.
Interactive API docs { #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):

Alternative API docs { #alternative-api-docs }
And now, go to http://127.0.0.1:8000/redoc.
You will see the alternative automatic documentation (provided by ReDoc):

Example upgrade { #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.
```Python hl_lines="4 9-12 25-27" 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/{itemid}") def readitem(itemid: int, q: Union[str, None] = None): return {"itemid": item_id, "q": q}
@app.put("/items/{itemid}") def updateitem(itemid: int, item: Item): return {"itemname": item.name, "itemid": itemid} ```
The fastapi dev server should reload automatically.
Interactive API docs upgrade { #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:

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

- 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:

Alternative API docs upgrade { #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:

Recap { #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:
Python
item_id: int
or for a more complex Item model:
Python
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). datetimeobjects.UUIDobjects.- Database models.
- ...and many more.
- Convert Python types (
- 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_idin the path forGETandPUTrequests. - Validate that the
item_idis of typeintforGETandPUTrequests.- If it is not, the client will see a useful, clear error.
- Check if there is an optional query parameter named
q(as inhttp://127.0.0.1:8000/items/foo?q=somequery) forGETrequests.- As the
qparameter is declared with= None, it is optional. - Without the
Noneit would be required (as is the body in the case withPUT).
- As the
- For
PUTrequests to/items/{item_id}, read the body as JSON:- Check that it has a required attribute
namethat should be astr. - Check that it has a required attribute
pricethat has to be afloat. - Check that it has an optional attribute
is_offer, that should be abool, if present. - All this would also work for deeply nested JSON objects.
- Check that it has a required attribute
- 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:
Python
return {"item_name": item.name, "item_id": item_id}
...from:
Python
... "item_name": item.name ...
...to:
Python
... "item_price": item.price ...
...and see how your editor will auto-complete the attributes and know their types:

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_lengthorregex. - 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 { #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 { #dependencies }
FastAPI depends on Pydantic and Starlette.
standard Dependencies { #standard-dependencies }
When you install FastAPI with pip install "fastapi[standard]" it comes with the standard group of optional dependencies:
Used by Pydantic:
email-validator- for email validation.
Used by Starlette:
httpx- Required if you want to use theTestClient.jinja2- Required if you want to use the default template configuration.python-multipart- Required if you want to support form "parsing", withrequest.form().
Used by FastAPI:
uvicorn- for the server that loads and serves your application. This includesuvicorn[standard], which includes some dependencies (e.g.uvloop) needed for high performance serving.fastapi-cli[standard]- to provide thefastapicommand.- This includes
fastapi-cloud-cli, which allows you to deploy your FastAPI application to FastAPI Cloud.
- This includes
Without standard Dependencies { #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 { #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 { #additional-optional-dependencies }
There are some additional dependencies you might want to install.
Additional optional Pydantic dependencies:
pydantic-settings- for settings management.pydantic-extra-types- for extra types to be used with Pydantic.
Additional optional FastAPI dependencies:
orjson- Required if you want to useORJSONResponse.ujson- Required if you want to useUJSONResponse.
License { #license }
This project is licensed under the terms of the MIT license.
Owner
- Name: FastAPI
- Login: fastapi
- Kind: organization
- Website: https://tiangolo.com/github-fastapi/
- Twitter: fastapi
- Repositories: 6
- Profile: https://github.com/fastapi
FastAPI and friends open source projects. Created and managed by @tiangolo.
Citation (CITATION.cff)
# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!
cff-version: 1.2.0
title: FastAPI
message: >-
If you use this software, please cite it using the
metadata from this file.
type: software
authors:
- given-names: Sebastián
family-names: Ramírez
email: tiangolo@gmail.com
identifiers:
repository-code: 'https://github.com/fastapi/fastapi'
url: 'https://fastapi.tiangolo.com'
abstract: >-
FastAPI framework, high performance, easy to learn, fast to code,
ready for production
keywords:
- fastapi
- pydantic
- starlette
license: MIT
Committers
Last synced: 5 months ago
Top Committers
| Name | Commits | |
|---|---|---|
| github-actions | g****s@g****m | 2,237 |
| Sebastián Ramírez | t****o@g****m | 1,731 |
| Nils Lindemann | n****n@t****m | 131 |
| dependabot[bot] | 4****] | 112 |
| Alejandra | 9****v | 51 |
| jaystone776 | j****6@g****m | 49 |
| pre-commit-ci[bot] | 6****] | 38 |
| github-actions[bot] | 4****] | 36 |
| Valentyn | v****n@g****m | 31 |
| Rafael de Oliveira Marques | r****s@g****m | 28 |
| Xie Wei | 3****v | 25 |
| T. Tokusumi | 4****i | 24 |
| Hasan Sezer Taşan | 1****n | 23 |
| Marcelo Trylesinski | m****e@g****m | 23 |
| SwftAlpc | a****t@g****m | 23 |
| dmontagu | 3****u | 17 |
| Aleksandr Andrukhov | d****v@g****m | 16 |
| Spike | r****4@g****m | 15 |
| YungYueh ChanLee | p****6@g****m | 14 |
| Zhongheng Cheng | z****7@c****u | 14 |
| João Pedro Pereira Holanda | j****9@g****m | 14 |
| euri10 | e****0 | 13 |
| Quentin Takeda | q****n@g****m | 13 |
| Vladislav Kramorenko | 8****s | 13 |
| Camila Gutierrez | m****l | 12 |
| Sam Courtemanche | s****o@g****m | 11 |
| Zhaohan Dong | 6****g | 11 |
| marcelomarkus | m****s@g****m | 11 |
| Kani Kim | k****8@g****m | 10 |
| alv2017 | v****e@g****m | 10 |
| and 791 more... | ||
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 4 months ago
All Time
- Total issues: 140
- Total pull requests: 2,560
- Average time to close issues: 21 days
- Average time to close pull requests: 3 months
- Total issue authors: 78
- Total pull request authors: 578
- Average comments per issue: 3.89
- Average comments per pull request: 2.73
- Merged pull requests: 1,148
- Bot issues: 1
- Bot pull requests: 173
Past Year
- Issues: 110
- Pull requests: 2,025
- Average time to close issues: 5 days
- Average time to close pull requests: 11 days
- Issue authors: 58
- Pull request authors: 380
- Average comments per issue: 1.69
- Average comments per pull request: 2.19
- Merged pull requests: 931
- Bot issues: 1
- Bot pull requests: 155
Top Authors
Issue Authors
- Kludex (16)
- AsyriaKiley (9)
- JerradGreenfield9 (8)
- floratyer (8)
- AkidaLipari (6)
- LajuanMorant (6)
- DaceRaynor (6)
- tiangolo (5)
- HibaSantiago (3)
- sm-Fifteen (2)
- codingjenny (2)
- kantandane (2)
- bowenerchen (2)
- zowi-net (1)
- AmanndaTopete (1)
Pull Request Authors
- tiangolo (372)
- dependabot[bot] (117)
- valentinDruzhinin (74)
- alejsdev (72)
- alissadb (72)
- AlexWendland (61)
- pre-commit-ci[bot] (56)
- ceb10n (41)
- alv2017 (38)
- zhaohan-dong (31)
- codingjenny (31)
- Zhongheng-Cheng (28)
- handabaldeep (27)
- kantandane (27)
- ptt3199 (26)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 6
-
Total downloads:
- pypi 123,259,992 last-month
- Total docker downloads: 184,796,512
-
Total dependent packages: 2,966
(may contain duplicates) -
Total dependent repositories: 43,737
(may contain duplicates) - Total versions: 326
- Total maintainers: 2
- Total advisories: 2
pypi.org: fastapi
FastAPI framework, high performance, easy to learn, fast to code, ready for production
- Homepage: https://github.com/fastapi/fastapi
- Documentation: https://fastapi.tiangolo.com/
- License: MIT License
-
Latest release: 0.116.1
published 6 months ago
Rankings
Maintainers (1)
Advisories (2)
conda-forge.org: fastapi
- Homepage: https://github.com/fastapi/fastapi
- License: MIT
-
Latest release: 0.87.0
published about 3 years ago
Rankings
proxy.golang.org: github.com/fastapi/fastapi
- Documentation: https://pkg.go.dev/github.com/fastapi/fastapi#section-documentation
- License: mit
-
Latest release: v0.1.16
published almost 7 years ago
Rankings
spack.io: py-fastapi
FastAPI framework, high performance, easy to learn, fast to code, ready for production
- Homepage: https://github.com/fastapi/fastapi
- License: []
-
Latest release: 0.115.4
published about 1 year ago
Rankings
Maintainers (1)
pypi.org: fastapi-slim
FastAPI framework, high performance, easy to learn, fast to code, ready for production
- Homepage: https://github.com/fastapi/fastapi
- Documentation: https://fastapi.tiangolo.com/
- License: MIT License
-
Latest release: 0.116.1
published 6 months ago
Rankings
Maintainers (1)
anaconda.org: fastapi
FastAPI is a modern, fast (high-performance), web framework for building APIs with Python 3.7+ 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.
- Homepage: https://github.com/fastapi/fastapi
- License: MIT
-
Latest release: 0.112.2
published over 1 year ago
Rankings
Dependencies
- Dockerfile * docker
- Dockerfile * docker
- Dockerfile * docker
- actions/cache v3 composite
- actions/checkout v3 composite
- actions/setup-python v4 composite
- actions/upload-artifact v3 composite
- dorny/paths-filter v2 composite
- re-actors/alls-green release/v1 composite
- ./.github/actions/comment-docs-preview-in-pr * composite
- actions/checkout v3 composite
- cloudflare/pages-action v1 composite
- dawidd6/action-download-artifact v2.27.0 composite
- tiangolo/issue-manager 0.4.0 composite
- docker://tiangolo/label-approved 0.0.2 composite
- actions/checkout v3 composite
- docker://tiangolo/latest-changes 0.0.3 composite
- mxschmitt/action-tmate v3 composite
- ./.github/actions/notify-translations * composite
- actions/checkout v3 composite
- mxschmitt/action-tmate v3 composite
- ./.github/actions/people * composite
- actions/checkout v3 composite
- mxschmitt/action-tmate v3 composite
- actions/cache v3 composite
- actions/checkout v3 composite
- actions/setup-python v4 composite
- pypa/gh-action-pypi-publish v1.8.6 composite
- actions/setup-python v4 composite
- dawidd6/action-download-artifact v2.27.0 composite
- actions/cache v3 composite
- actions/checkout v3 composite
- actions/download-artifact v3 composite
- actions/setup-python v4 composite
- actions/upload-artifact v3 composite
- re-actors/alls-green release/v1 composite
- python 3.7 build
- python 3.7 build
- python 3.9 build
- anyio >=3.7.1,<4.0.0
- pydantic >=1.7.4,!=1.8,!=1.8.1,!=2.0.0,!=2.0.1,!=2.1.0,<3.0.0
- starlette >=0.27.0,<0.28.0
- typing-extensions >=4.5.0
- cairosvg ==2.7.0
- jieba ==0.42.1
- mdx-include >=1.4.1,<2.0.0
- mkdocs-markdownextradata-plugin >=0.1.7,<0.3.0
- mkdocs-material ==9.1.21
- mkdocs-redirects >=1.2.1,<1.3.0
- pillow ==9.5.0
- pyyaml >=5.3.1,<7.0.0
- typer >=0.6.1,<0.8.0
- typer-cli >=0.0.13,<0.0.14
- anyio >=3.2.1,<4.0.0 test
- black ==23.3.0 test
- coverage >=6.5.0,<8.0 test
- databases >=0.3.2,<0.7.0 test
- dirty-equals ==0.6.0 test
- email_validator >=1.1.1,<3.0.0 test
- flask >=1.1.2,<3.0.0 test
- httpx >=0.23.0,<0.25.0 test
- mypy ==1.4.1 test
- orjson >=3.2.1,<4.0.0 test
- passlib >=1.7.2,<2.0.0 test
- pydantic-settings >=2.0.0 test
- pytest >=7.1.3,<8.0.0 test
- python-jose >=3.3.0,<4.0.0 test
- python-multipart >=0.0.5,<0.0.7 test
- pyyaml >=5.3.1,<7.0.0 test
- ruff ==0.0.275 test
- sqlalchemy >=1.3.18,<1.4.43 test
- types-orjson ==3.6.2 test
- types-ujson ==5.7.0.1 test
- ujson >=4.0.1, test
- playwright *
- pre-commit >=2.17.0,<4.0.0
- uvicorn >=0.12.0,<0.23.0
- httpx >=0.23.0,<0.25.0 test











