{"id":13374240,"url":"https://github.com/fastapi/fastapi","last_synced_at":"2026-02-21T19:17:23.153Z","repository":{"id":37270611,"uuid":"160919119","full_name":"fastapi/fastapi","owner":"fastapi","description":"FastAPI framework, high performance, easy to learn, fast to code, ready for production","archived":false,"fork":false,"pushed_at":"2025-09-05T12:49:23.000Z","size":28209,"stargazers_count":89175,"open_issues_count":235,"forks_count":7831,"subscribers_count":715,"default_branch":"master","last_synced_at":"2025-09-06T00:57:34.643Z","etag":null,"topics":["api","async","asyncio","fastapi","framework","json","json-schema","openapi","openapi3","pydantic","python","python-types","python3","redoc","rest","starlette","swagger","swagger-ui","uvicorn","web"],"latest_commit_sha":null,"homepage":"https://fastapi.tiangolo.com/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fastapi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["tiangolo"]}},"created_at":"2018-12-08T08:21:47.000Z","updated_at":"2025-09-06T00:40:53.000Z","dependencies_parsed_at":"2023-12-25T20:10:00.359Z","dependency_job_id":"56b5d4aa-414f-4e5d-8674-5b22833ab3af","html_url":"https://github.com/fastapi/fastapi","commit_stats":{"total_commits":5188,"total_committers":764,"mean_commits":6.790575916230367,"dds":0.6380107941403238,"last_synced_commit":"1cfea408c0e7b516f6526682dc5c4cc938c9d62f"},"previous_names":["fastapi/fastapi"],"tags_count":212,"template":false,"template_full_name":null,"purl":"pkg:github/fastapi/fastapi","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastapi%2Ffastapi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastapi%2Ffastapi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastapi%2Ffastapi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastapi%2Ffastapi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fastapi","download_url":"https://codeload.github.com/fastapi/fastapi/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fastapi%2Ffastapi/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273932764,"owners_count":25193599,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-06T02:00:13.247Z","response_time":2576,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","async","asyncio","fastapi","framework","json","json-schema","openapi","openapi3","pydantic","python","python-types","python3","redoc","rest","starlette","swagger","swagger-ui","uvicorn","web"],"created_at":"2024-07-30T05:00:42.164Z","updated_at":"2026-02-21T19:17:23.140Z","avatar_url":"https://github.com/fastapi.png","language":"Python","readme":"\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://fastapi.tiangolo.com\"\u003e\u003cimg src=\"https://fastapi.tiangolo.com/img/logo-margin/logo-teal.png\" alt=\"FastAPI\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n    \u003cem\u003eFastAPI framework, high performance, easy to learn, fast to code, ready for production\u003c/em\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/fastapi/fastapi/actions?query=workflow%3ATest+event%3Apush+branch%3Amaster\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://github.com/fastapi/fastapi/actions/workflows/test.yml/badge.svg?event=push\u0026branch=master\" alt=\"Test\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://coverage-badge.samuelcolvin.workers.dev/redirect/fastapi/fastapi\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://coverage-badge.samuelcolvin.workers.dev/fastapi/fastapi.svg\" alt=\"Coverage\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://pypi.org/project/fastapi\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://img.shields.io/pypi/v/fastapi?color=%2334D058\u0026label=pypi%20package\" alt=\"Package version\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://pypi.org/project/fastapi\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://img.shields.io/pypi/pyversions/fastapi.svg?color=%2334D058\" alt=\"Supported Python versions\"\u003e\n\u003c/a\u003e\n\u003c/p\u003e\n\n---\n\n**Documentation**: \u003ca href=\"https://fastapi.tiangolo.com\" target=\"_blank\"\u003ehttps://fastapi.tiangolo.com\u003c/a\u003e\n\n**Source Code**: \u003ca href=\"https://github.com/fastapi/fastapi\" target=\"_blank\"\u003ehttps://github.com/fastapi/fastapi\u003c/a\u003e\n\n---\n\nFastAPI is a modern, fast (high-performance), web framework for building APIs with Python based on standard Python type hints.\n\nThe key features are:\n\n* **Fast**: Very high performance, on par with **NodeJS** and **Go** (thanks to Starlette and Pydantic). [One of the fastest Python frameworks available](#performance).\n* **Fast to code**: Increase the speed to develop features by about 200% to 300%. *\n* **Fewer bugs**: Reduce about 40% of human (developer) induced errors. *\n* **Intuitive**: Great editor support. \u003cdfn title=\"also known as auto-complete, autocompletion, IntelliSense\"\u003eCompletion\u003c/dfn\u003e everywhere. Less time debugging.\n* **Easy**: Designed to be easy to use and learn. Less time reading docs.\n* **Short**: Minimize code duplication. Multiple features from each parameter declaration. Fewer bugs.\n* **Robust**: Get production-ready code. With automatic interactive documentation.\n* **Standards-based**: Based on (and fully compatible with) the open standards for APIs: \u003ca href=\"https://github.com/OAI/OpenAPI-Specification\" class=\"external-link\" target=\"_blank\"\u003eOpenAPI\u003c/a\u003e (previously known as Swagger) and \u003ca href=\"https://json-schema.org/\" class=\"external-link\" target=\"_blank\"\u003eJSON Schema\u003c/a\u003e.\n\n\u003csmall\u003e* estimation based on tests conducted by an internal development team, building production applications.\u003c/small\u003e\n\n## Sponsors\n\n\u003c!-- sponsors --\u003e\n### Keystone Sponsor\n\n\u003ca href=\"https://fastapicloud.com\" target=\"_blank\" title=\"FastAPI Cloud. By the same team behind FastAPI. You code. We Cloud.\"\u003e\u003cimg src=\"https://fastapi.tiangolo.com/img/sponsors/fastapicloud.png\"\u003e\u003c/a\u003e\n\n### Gold and Silver Sponsors\n\n\u003ca href=\"https://blockbee.io?ref=fastapi\" target=\"_blank\" title=\"BlockBee Cryptocurrency Payment Gateway\"\u003e\u003cimg src=\"https://fastapi.tiangolo.com/img/sponsors/blockbee.png\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/scalar/scalar/?utm_source=fastapi\u0026utm_medium=website\u0026utm_campaign=main-badge\" target=\"_blank\" title=\"Scalar: Beautiful Open-Source API References from Swagger/OpenAPI files\"\u003e\u003cimg src=\"https://fastapi.tiangolo.com/img/sponsors/scalar.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.propelauth.com/?utm_source=fastapi\u0026utm_campaign=1223\u0026utm_medium=mainbadge\" target=\"_blank\" title=\"Auth, user management and more for your B2B product\"\u003e\u003cimg src=\"https://fastapi.tiangolo.com/img/sponsors/propelauth.png\"\u003e\u003c/a\u003e\n\u003ca href=\"https://zuplo.link/fastapi-gh\" target=\"_blank\" title=\"Zuplo: Deploy, Secure, Document, and Monetize your FastAPI\"\u003e\u003cimg src=\"https://fastapi.tiangolo.com/img/sponsors/zuplo.png\"\u003e\u003c/a\u003e\n\u003ca href=\"https://liblab.com?utm_source=fastapi\" target=\"_blank\" title=\"liblab - Generate SDKs from FastAPI\"\u003e\u003cimg src=\"https://fastapi.tiangolo.com/img/sponsors/liblab.png\"\u003e\u003c/a\u003e\n\u003ca href=\"https://docs.render.com/deploy-fastapi?utm_source=deploydoc\u0026utm_medium=referral\u0026utm_campaign=fastapi\" target=\"_blank\" title=\"Deploy \u0026 scale any full-stack web app on Render. Focus on building apps, not infra.\"\u003e\u003cimg src=\"https://fastapi.tiangolo.com/img/sponsors/render.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.coderabbit.ai/?utm_source=fastapi\u0026utm_medium=badge\u0026utm_campaign=fastapi\" target=\"_blank\" title=\"Cut Code Review Time \u0026 Bugs in Half with CodeRabbit\"\u003e\u003cimg src=\"https://fastapi.tiangolo.com/img/sponsors/coderabbit.png\"\u003e\u003c/a\u003e\n\u003ca href=\"https://subtotal.com/?utm_source=fastapi\u0026utm_medium=sponsorship\u0026utm_campaign=open-source\" target=\"_blank\" title=\"The Gold Standard in Retail Account Linking\"\u003e\u003cimg src=\"https://fastapi.tiangolo.com/img/sponsors/subtotal.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://docs.railway.com/guides/fastapi?utm_medium=integration\u0026utm_source=docs\u0026utm_campaign=fastapi\" target=\"_blank\" title=\"Deploy enterprise applications at startup speed\"\u003e\u003cimg src=\"https://fastapi.tiangolo.com/img/sponsors/railway.png\"\u003e\u003c/a\u003e\n\u003ca href=\"https://serpapi.com/?utm_source=fastapi_website\" target=\"_blank\" title=\"SerpApi: Web Search API\"\u003e\u003cimg src=\"https://fastapi.tiangolo.com/img/sponsors/serpapi.png\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.greptile.com/?utm_source=fastapi\u0026utm_medium=sponsorship\u0026utm_campaign=fastapi_sponsor_page\" target=\"_blank\" title=\"Greptile: The AI Code Reviewer\"\u003e\u003cimg src=\"https://fastapi.tiangolo.com/img/sponsors/greptile.png\"\u003e\u003c/a\u003e\n\u003ca href=\"https://databento.com/?utm_source=fastapi\u0026utm_medium=sponsor\u0026utm_content=display\" target=\"_blank\" title=\"Pay as you go for market data\"\u003e\u003cimg src=\"https://fastapi.tiangolo.com/img/sponsors/databento.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://speakeasy.com/editor?utm_source=fastapi+repo\u0026utm_medium=github+sponsorship\" target=\"_blank\" title=\"SDKs for your API | Speakeasy\"\u003e\u003cimg src=\"https://fastapi.tiangolo.com/img/sponsors/speakeasy.png\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.svix.com/\" target=\"_blank\" title=\"Svix - Webhooks as a service\"\u003e\u003cimg src=\"https://fastapi.tiangolo.com/img/sponsors/svix.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.stainlessapi.com/?utm_source=fastapi\u0026utm_medium=referral\" target=\"_blank\" title=\"Stainless | Generate best-in-class SDKs\"\u003e\u003cimg src=\"https://fastapi.tiangolo.com/img/sponsors/stainless.png\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.permit.io/blog/implement-authorization-in-fastapi?utm_source=github\u0026utm_medium=referral\u0026utm_campaign=fastapi\" target=\"_blank\" title=\"Fine-Grained Authorization for FastAPI\"\u003e\u003cimg src=\"https://fastapi.tiangolo.com/img/sponsors/permit.png\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.interviewpal.com/?utm_source=fastapi\u0026utm_medium=open-source\u0026utm_campaign=dev-hiring\" target=\"_blank\" title=\"InterviewPal - AI Interview Coach for Engineers and Devs\"\u003e\u003cimg src=\"https://fastapi.tiangolo.com/img/sponsors/interviewpal.png\"\u003e\u003c/a\u003e\n\u003ca href=\"https://dribia.com/en/\" target=\"_blank\" title=\"Dribia - Data Science within your reach\"\u003e\u003cimg src=\"https://fastapi.tiangolo.com/img/sponsors/dribia.png\"\u003e\u003c/a\u003e\n\n\u003c!-- /sponsors --\u003e\n\n\u003ca href=\"https://fastapi.tiangolo.com/fastapi-people/#sponsors\" class=\"external-link\" target=\"_blank\"\u003eOther sponsors\u003c/a\u003e\n\n## Opinions\n\n\"_[...] 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._\"\n\n\u003cdiv style=\"text-align: right; margin-right: 10%;\"\u003eKabir Khan - \u003cstrong\u003eMicrosoft\u003c/strong\u003e \u003ca href=\"https://github.com/fastapi/fastapi/pull/26\" target=\"_blank\"\u003e\u003csmall\u003e(ref)\u003c/small\u003e\u003c/a\u003e\u003c/div\u003e\n\n---\n\n\"_We adopted the **FastAPI** library to spawn a **REST** server that can be queried to obtain **predictions**. [for Ludwig]_\"\n\n\u003cdiv style=\"text-align: right; margin-right: 10%;\"\u003ePiero Molino, Yaroslav Dudin, and Sai Sumanth Miryala - \u003cstrong\u003eUber\u003c/strong\u003e \u003ca href=\"https://eng.uber.com/ludwig-v0-2/\" target=\"_blank\"\u003e\u003csmall\u003e(ref)\u003c/small\u003e\u003c/a\u003e\u003c/div\u003e\n\n---\n\n\"_**Netflix** is pleased to announce the open-source release of our **crisis management** orchestration framework: **Dispatch**! [built with **FastAPI**]_\"\n\n\u003cdiv style=\"text-align: right; margin-right: 10%;\"\u003eKevin Glisson, Marc Vilanova, Forest Monsen - \u003cstrong\u003eNetflix\u003c/strong\u003e \u003ca href=\"https://netflixtechblog.com/introducing-dispatch-da4b8a2a8072\" target=\"_blank\"\u003e\u003csmall\u003e(ref)\u003c/small\u003e\u003c/a\u003e\u003c/div\u003e\n\n---\n\n\"_I’m over the moon excited about **FastAPI**. It’s so fun!_\"\n\n\u003cdiv style=\"text-align: right; margin-right: 10%;\"\u003eBrian Okken - \u003cstrong\u003e\u003ca href=\"https://pythonbytes.fm/episodes/show/123/time-to-right-the-py-wrongs?time_in_sec=855\" target=\"_blank\"\u003ePython Bytes\u003c/a\u003e podcast host\u003c/strong\u003e \u003ca href=\"https://x.com/brianokken/status/1112220079972728832\" target=\"_blank\"\u003e\u003csmall\u003e(ref)\u003c/small\u003e\u003c/a\u003e\u003c/div\u003e\n\n---\n\n\"_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._\"\n\n\u003cdiv style=\"text-align: right; margin-right: 10%;\"\u003eTimothy Crosley - \u003cstrong\u003e\u003ca href=\"https://github.com/hugapi/hug\" target=\"_blank\"\u003eHug\u003c/a\u003e creator\u003c/strong\u003e \u003ca href=\"https://news.ycombinator.com/item?id=19455465\" target=\"_blank\"\u003e\u003csmall\u003e(ref)\u003c/small\u003e\u003c/a\u003e\u003c/div\u003e\n\n---\n\n\"_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 [...]_\"\n\n\"_We've switched over to **FastAPI** for our **APIs** [...] I think you'll like it [...]_\"\n\n\u003cdiv style=\"text-align: right; margin-right: 10%;\"\u003eInes Montani - Matthew Honnibal - \u003cstrong\u003e\u003ca href=\"https://explosion.ai\" target=\"_blank\"\u003eExplosion AI\u003c/a\u003e founders - \u003ca href=\"https://spacy.io\" target=\"_blank\"\u003espaCy\u003c/a\u003e creators\u003c/strong\u003e \u003ca href=\"https://x.com/_inesmontani/status/1144173225322143744\" target=\"_blank\"\u003e\u003csmall\u003e(ref)\u003c/small\u003e\u003c/a\u003e - \u003ca href=\"https://x.com/honnibal/status/1144031421859655680\" target=\"_blank\"\u003e\u003csmall\u003e(ref)\u003c/small\u003e\u003c/a\u003e\u003c/div\u003e\n\n---\n\n\"_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._\"\n\n\u003cdiv style=\"text-align: right; margin-right: 10%;\"\u003eDeon Pillsbury - \u003cstrong\u003eCisco\u003c/strong\u003e \u003ca href=\"https://www.linkedin.com/posts/deonpillsbury_cisco-cx-python-activity-6963242628536487936-trAp/\" target=\"_blank\"\u003e\u003csmall\u003e(ref)\u003c/small\u003e\u003c/a\u003e\u003c/div\u003e\n\n---\n\n## FastAPI mini documentary\n\nThere's a \u003ca href=\"https://www.youtube.com/watch?v=mpR8ngthqiE\" class=\"external-link\" target=\"_blank\"\u003eFastAPI mini documentary\u003c/a\u003e released at the end of 2025, you can watch it online:\n\n\u003ca href=\"https://www.youtube.com/watch?v=mpR8ngthqiE\" target=\"_blank\"\u003e\u003cimg src=\"https://fastapi.tiangolo.com/img/fastapi-documentary.jpg\" alt=\"FastAPI Mini Documentary\"\u003e\u003c/a\u003e\n\n## **Typer**, the FastAPI of CLIs\n\n\u003ca href=\"https://typer.tiangolo.com\" target=\"_blank\"\u003e\u003cimg src=\"https://typer.tiangolo.com/img/logo-margin/logo-margin-vector.svg\" style=\"width: 20%;\"\u003e\u003c/a\u003e\n\nIf you are building a \u003cabbr title=\"Command Line Interface\"\u003eCLI\u003c/abbr\u003e app to be used in the terminal instead of a web API, check out \u003ca href=\"https://typer.tiangolo.com/\" class=\"external-link\" target=\"_blank\"\u003e**Typer**\u003c/a\u003e.\n\n**Typer** is FastAPI's little sibling. And it's intended to be the **FastAPI of CLIs**. ⌨️ 🚀\n\n## Requirements\n\nFastAPI stands on the shoulders of giants:\n\n* \u003ca href=\"https://www.starlette.dev/\" class=\"external-link\" target=\"_blank\"\u003eStarlette\u003c/a\u003e for the web parts.\n* \u003ca href=\"https://docs.pydantic.dev/\" class=\"external-link\" target=\"_blank\"\u003ePydantic\u003c/a\u003e for the data parts.\n\n## Installation\n\nCreate and activate a \u003ca href=\"https://fastapi.tiangolo.com/virtual-environments/\" class=\"external-link\" target=\"_blank\"\u003evirtual environment\u003c/a\u003e and then install FastAPI:\n\n\u003cdiv class=\"termy\"\u003e\n\n```console\n$ pip install \"fastapi[standard]\"\n\n---\u003e 100%\n```\n\n\u003c/div\u003e\n\n**Note**: Make sure you put `\"fastapi[standard]\"` in quotes to ensure it works in all terminals.\n\n## Example\n\n### Create it\n\nCreate a file `main.py` with:\n\n```Python\nfrom fastapi import FastAPI\n\napp = FastAPI()\n\n\n@app.get(\"/\")\ndef read_root():\n    return {\"Hello\": \"World\"}\n\n\n@app.get(\"/items/{item_id}\")\ndef read_item(item_id: int, q: str | None = None):\n    return {\"item_id\": item_id, \"q\": q}\n```\n\n\u003cdetails markdown=\"1\"\u003e\n\u003csummary\u003eOr use \u003ccode\u003easync def\u003c/code\u003e...\u003c/summary\u003e\n\nIf your code uses `async` / `await`, use `async def`:\n\n```Python hl_lines=\"7  12\"\nfrom fastapi import FastAPI\n\napp = FastAPI()\n\n\n@app.get(\"/\")\nasync def read_root():\n    return {\"Hello\": \"World\"}\n\n\n@app.get(\"/items/{item_id}\")\nasync def read_item(item_id: int, q: str | None = None):\n    return {\"item_id\": item_id, \"q\": q}\n```\n\n**Note**:\n\nIf you don't know, check the _\"In a hurry?\"_ section about \u003ca href=\"https://fastapi.tiangolo.com/async/#in-a-hurry\" target=\"_blank\"\u003e`async` and `await` in the docs\u003c/a\u003e.\n\n\u003c/details\u003e\n\n### Run it\n\nRun the server with:\n\n\u003cdiv class=\"termy\"\u003e\n\n```console\n$ fastapi dev main.py\n\n ╭────────── FastAPI CLI - Development mode ───────────╮\n │                                                     │\n │  Serving at: http://127.0.0.1:8000                  │\n │                                                     │\n │  API docs: http://127.0.0.1:8000/docs               │\n │                                                     │\n │  Running in development mode, for production use:   │\n │                                                     │\n │  fastapi run                                        │\n │                                                     │\n ╰─────────────────────────────────────────────────────╯\n\nINFO:     Will watch for changes in these directories: ['/home/user/code/awesomeapp']\nINFO:     Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)\nINFO:     Started reloader process [2248755] using WatchFiles\nINFO:     Started server process [2248757]\nINFO:     Waiting for application startup.\nINFO:     Application startup complete.\n```\n\n\u003c/div\u003e\n\n\u003cdetails markdown=\"1\"\u003e\n\u003csummary\u003eAbout the command \u003ccode\u003efastapi dev main.py\u003c/code\u003e...\u003c/summary\u003e\n\nThe command `fastapi dev` reads your `main.py` file, detects the **FastAPI** app in it, and starts a server using \u003ca href=\"https://www.uvicorn.dev\" class=\"external-link\" target=\"_blank\"\u003eUvicorn\u003c/a\u003e.\n\nBy default, `fastapi dev` will start with auto-reload enabled for local development.\n\nYou can read more about it in the \u003ca href=\"https://fastapi.tiangolo.com/fastapi-cli/\" target=\"_blank\"\u003eFastAPI CLI docs\u003c/a\u003e.\n\n\u003c/details\u003e\n\n### Check it\n\nOpen your browser at \u003ca href=\"http://127.0.0.1:8000/items/5?q=somequery\" class=\"external-link\" target=\"_blank\"\u003ehttp://127.0.0.1:8000/items/5?q=somequery\u003c/a\u003e.\n\nYou will see the JSON response as:\n\n```JSON\n{\"item_id\": 5, \"q\": \"somequery\"}\n```\n\nYou already created an API that:\n\n* Receives HTTP requests in the _paths_ `/` and `/items/{item_id}`.\n* Both _paths_ take `GET` \u003cem\u003eoperations\u003c/em\u003e (also known as HTTP _methods_).\n* The _path_ `/items/{item_id}` has a _path parameter_ `item_id` that should be an `int`.\n* The _path_ `/items/{item_id}` has an optional `str` _query parameter_ `q`.\n\n### Interactive API docs\n\nNow go to \u003ca href=\"http://127.0.0.1:8000/docs\" class=\"external-link\" target=\"_blank\"\u003ehttp://127.0.0.1:8000/docs\u003c/a\u003e.\n\nYou will see the automatic interactive API documentation (provided by \u003ca href=\"https://github.com/swagger-api/swagger-ui\" class=\"external-link\" target=\"_blank\"\u003eSwagger UI\u003c/a\u003e):\n\n![Swagger UI](https://fastapi.tiangolo.com/img/index/index-01-swagger-ui-simple.png)\n\n### Alternative API docs\n\nAnd now, go to \u003ca href=\"http://127.0.0.1:8000/redoc\" class=\"external-link\" target=\"_blank\"\u003ehttp://127.0.0.1:8000/redoc\u003c/a\u003e.\n\nYou will see the alternative automatic documentation (provided by \u003ca href=\"https://github.com/Rebilly/ReDoc\" class=\"external-link\" target=\"_blank\"\u003eReDoc\u003c/a\u003e):\n\n![ReDoc](https://fastapi.tiangolo.com/img/index/index-02-redoc-simple.png)\n\n## Example upgrade\n\nNow modify the file `main.py` to receive a body from a `PUT` request.\n\nDeclare the body using standard Python types, thanks to Pydantic.\n\n```Python hl_lines=\"2  7-10 23-25\"\nfrom fastapi import FastAPI\nfrom pydantic import BaseModel\n\napp = FastAPI()\n\n\nclass Item(BaseModel):\n    name: str\n    price: float\n    is_offer: bool | None = None\n\n\n@app.get(\"/\")\ndef read_root():\n    return {\"Hello\": \"World\"}\n\n\n@app.get(\"/items/{item_id}\")\ndef read_item(item_id: int, q: str | None = None):\n    return {\"item_id\": item_id, \"q\": q}\n\n\n@app.put(\"/items/{item_id}\")\ndef update_item(item_id: int, item: Item):\n    return {\"item_name\": item.name, \"item_id\": item_id}\n```\n\nThe `fastapi dev` server should reload automatically.\n\n### Interactive API docs upgrade\n\nNow go to \u003ca href=\"http://127.0.0.1:8000/docs\" class=\"external-link\" target=\"_blank\"\u003ehttp://127.0.0.1:8000/docs\u003c/a\u003e.\n\n* The interactive API documentation will be automatically updated, including the new body:\n\n![Swagger UI](https://fastapi.tiangolo.com/img/index/index-03-swagger-02.png)\n\n* Click on the button \"Try it out\", it allows you to fill the parameters and directly interact with the API:\n\n![Swagger UI interaction](https://fastapi.tiangolo.com/img/index/index-04-swagger-03.png)\n\n* 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:\n\n![Swagger UI interaction](https://fastapi.tiangolo.com/img/index/index-05-swagger-04.png)\n\n### Alternative API docs upgrade\n\nAnd now, go to \u003ca href=\"http://127.0.0.1:8000/redoc\" class=\"external-link\" target=\"_blank\"\u003ehttp://127.0.0.1:8000/redoc\u003c/a\u003e.\n\n* The alternative documentation will also reflect the new query parameter and body:\n\n![ReDoc](https://fastapi.tiangolo.com/img/index/index-06-redoc-02.png)\n\n### Recap\n\nIn summary, you declare **once** the types of parameters, body, etc. as function parameters.\n\nYou do that with standard modern Python types.\n\nYou don't have to learn a new syntax, the methods or classes of a specific library, etc.\n\nJust standard **Python**.\n\nFor example, for an `int`:\n\n```Python\nitem_id: int\n```\n\nor for a more complex `Item` model:\n\n```Python\nitem: Item\n```\n\n...and with that single declaration you get:\n\n* Editor support, including:\n    * Completion.\n    * Type checks.\n* Validation of data:\n    * Automatic and clear errors when the data is invalid.\n    * Validation even for deeply nested JSON objects.\n* \u003cdfn title=\"also known as: serialization, parsing, marshalling\"\u003eConversion\u003c/dfn\u003e of input data: coming from the network to Python data and types. Reading from:\n    * JSON.\n    * Path parameters.\n    * Query parameters.\n    * Cookies.\n    * Headers.\n    * Forms.\n    * Files.\n* \u003cdfn title=\"also known as: serialization, parsing, marshalling\"\u003eConversion\u003c/dfn\u003e of output data: converting from Python data and types to network data (as JSON):\n    * Convert Python types (`str`, `int`, `float`, `bool`, `list`, etc).\n    * `datetime` objects.\n    * `UUID` objects.\n    * Database models.\n    * ...and many more.\n* Automatic interactive API documentation, including 2 alternative user interfaces:\n    * Swagger UI.\n    * ReDoc.\n\n---\n\nComing back to the previous code example, **FastAPI** will:\n\n* Validate that there is an `item_id` in the path for `GET` and `PUT` requests.\n* Validate that the `item_id` is of type `int` for `GET` and `PUT` requests.\n    * If it is not, the client will see a useful, clear error.\n* 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.\n    * As the `q` parameter is declared with `= None`, it is optional.\n    * Without the `None` it would be required (as is the body in the case with `PUT`).\n* For `PUT` requests to `/items/{item_id}`, read the body as JSON:\n    * Check that it has a required attribute `name` that should be a `str`.\n    * Check that it has a required attribute `price` that has to be a `float`.\n    * Check that it has an optional attribute `is_offer`, that should be a `bool`, if present.\n    * All this would also work for deeply nested JSON objects.\n* Convert from and to JSON automatically.\n* Document everything with OpenAPI, that can be used by:\n    * Interactive documentation systems.\n    * Automatic client code generation systems, for many languages.\n* Provide 2 interactive documentation web interfaces directly.\n\n---\n\nWe just scratched the surface, but you already get the idea of how it all works.\n\nTry changing the line with:\n\n```Python\n    return {\"item_name\": item.name, \"item_id\": item_id}\n```\n\n...from:\n\n```Python\n        ... \"item_name\": item.name ...\n```\n\n...to:\n\n```Python\n        ... \"item_price\": item.price ...\n```\n\n...and see how your editor will auto-complete the attributes and know their types:\n\n![editor support](https://fastapi.tiangolo.com/img/vscode-completion.png)\n\nFor a more complete example including more features, see the \u003ca href=\"https://fastapi.tiangolo.com/tutorial/\"\u003eTutorial - User Guide\u003c/a\u003e.\n\n**Spoiler alert**: the tutorial - user guide includes:\n\n* Declaration of **parameters** from other different places as: **headers**, **cookies**, **form fields** and **files**.\n* How to set **validation constraints** as `maximum_length` or `regex`.\n* A very powerful and easy to use **\u003cdfn title=\"also known as components, resources, providers, services, injectables\"\u003eDependency Injection\u003c/dfn\u003e** system.\n* Security and authentication, including support for **OAuth2** with **JWT tokens** and **HTTP Basic** auth.\n* More advanced (but equally easy) techniques for declaring **deeply nested JSON models** (thanks to Pydantic).\n* **GraphQL** integration with \u003ca href=\"https://strawberry.rocks\" class=\"external-link\" target=\"_blank\"\u003eStrawberry\u003c/a\u003e and other libraries.\n* Many extra features (thanks to Starlette) as:\n    * **WebSockets**\n    * extremely easy tests based on HTTPX and `pytest`\n    * **CORS**\n    * **Cookie Sessions**\n    * ...and more.\n\n### Deploy your app (optional)\n\nYou can optionally deploy your FastAPI app to \u003ca href=\"https://fastapicloud.com\" class=\"external-link\" target=\"_blank\"\u003eFastAPI Cloud\u003c/a\u003e, go and join the waiting list if you haven't. 🚀\n\nIf you already have a **FastAPI Cloud** account (we invited you from the waiting list 😉), you can deploy your application with one command.\n\nBefore deploying, make sure you are logged in:\n\n\u003cdiv class=\"termy\"\u003e\n\n```console\n$ fastapi login\n\nYou are logged in to FastAPI Cloud 🚀\n```\n\n\u003c/div\u003e\n\nThen deploy your app:\n\n\u003cdiv class=\"termy\"\u003e\n\n```console\n$ fastapi deploy\n\nDeploying to FastAPI Cloud...\n\n✅ Deployment successful!\n\n🐔 Ready the chicken! Your app is ready at https://myapp.fastapicloud.dev\n```\n\n\u003c/div\u003e\n\nThat's it! Now you can access your app at that URL. ✨\n\n#### About FastAPI Cloud\n\n**\u003ca href=\"https://fastapicloud.com\" class=\"external-link\" target=\"_blank\"\u003eFastAPI Cloud\u003c/a\u003e** is built by the same author and team behind **FastAPI**.\n\nIt streamlines the process of **building**, **deploying**, and **accessing** an API with minimal effort.\n\nIt brings the same **developer experience** of building apps with FastAPI to **deploying** them to the cloud. 🎉\n\nFastAPI Cloud is the primary sponsor and funding provider for the *FastAPI and friends* open source projects. ✨\n\n#### Deploy to other cloud providers\n\nFastAPI is open source and based on standards. You can deploy FastAPI apps to any cloud provider you choose.\n\nFollow your cloud provider's guides to deploy FastAPI apps with them. 🤓\n\n## Performance\n\nIndependent TechEmpower benchmarks show **FastAPI** applications running under Uvicorn as \u003ca href=\"https://www.techempower.com/benchmarks/#section=test\u0026runid=7464e520-0dc2-473d-bd34-dbdfd7e85911\u0026hw=ph\u0026test=query\u0026l=zijzen-7\" class=\"external-link\" target=\"_blank\"\u003eone of the fastest Python frameworks available\u003c/a\u003e, only below Starlette and Uvicorn themselves (used internally by FastAPI). (*)\n\nTo understand more about it, see the section \u003ca href=\"https://fastapi.tiangolo.com/benchmarks/\" class=\"internal-link\" target=\"_blank\"\u003eBenchmarks\u003c/a\u003e.\n\n## Dependencies\n\nFastAPI depends on Pydantic and Starlette.\n\n### `standard` Dependencies\n\nWhen you install FastAPI with `pip install \"fastapi[standard]\"` it comes with the `standard` group of optional dependencies:\n\nUsed by Pydantic:\n\n* \u003ca href=\"https://github.com/JoshData/python-email-validator\" target=\"_blank\"\u003e\u003ccode\u003eemail-validator\u003c/code\u003e\u003c/a\u003e - for email validation.\n\nUsed by Starlette:\n\n* \u003ca href=\"https://www.python-httpx.org\" target=\"_blank\"\u003e\u003ccode\u003ehttpx\u003c/code\u003e\u003c/a\u003e - Required if you want to use the `TestClient`.\n* \u003ca href=\"https://jinja.palletsprojects.com\" target=\"_blank\"\u003e\u003ccode\u003ejinja2\u003c/code\u003e\u003c/a\u003e - Required if you want to use the default template configuration.\n* \u003ca href=\"https://github.com/Kludex/python-multipart\" target=\"_blank\"\u003e\u003ccode\u003epython-multipart\u003c/code\u003e\u003c/a\u003e - Required if you want to support form \u003cdfn title=\"converting the string that comes from an HTTP request into Python data\"\u003e\"parsing\"\u003c/dfn\u003e, with `request.form()`.\n\nUsed by FastAPI:\n\n* \u003ca href=\"https://www.uvicorn.dev\" target=\"_blank\"\u003e\u003ccode\u003euvicorn\u003c/code\u003e\u003c/a\u003e - 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.\n* `fastapi-cli[standard]` - to provide the `fastapi` command.\n    * This includes `fastapi-cloud-cli`, which allows you to deploy your FastAPI application to \u003ca href=\"https://fastapicloud.com\" class=\"external-link\" target=\"_blank\"\u003eFastAPI Cloud\u003c/a\u003e.\n\n### Without `standard` Dependencies\n\nIf you don't want to include the `standard` optional dependencies, you can install with `pip install fastapi` instead of `pip install \"fastapi[standard]\"`.\n\n### Without `fastapi-cloud-cli`\n\nIf 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]\"`.\n\n### Additional Optional Dependencies\n\nThere are some additional dependencies you might want to install.\n\nAdditional optional Pydantic dependencies:\n\n* \u003ca href=\"https://docs.pydantic.dev/latest/usage/pydantic_settings/\" target=\"_blank\"\u003e\u003ccode\u003epydantic-settings\u003c/code\u003e\u003c/a\u003e - for settings management.\n* \u003ca href=\"https://docs.pydantic.dev/latest/usage/types/extra_types/extra_types/\" target=\"_blank\"\u003e\u003ccode\u003epydantic-extra-types\u003c/code\u003e\u003c/a\u003e - for extra types to be used with Pydantic.\n\nAdditional optional FastAPI dependencies:\n\n* \u003ca href=\"https://github.com/ijl/orjson\" target=\"_blank\"\u003e\u003ccode\u003eorjson\u003c/code\u003e\u003c/a\u003e - Required if you want to use `ORJSONResponse`.\n* \u003ca href=\"https://github.com/esnme/ultrajson\" target=\"_blank\"\u003e\u003ccode\u003eujson\u003c/code\u003e\u003c/a\u003e - Required if you want to use `UJSONResponse`.\n\n## License\n\nThis project is licensed under the terms of the MIT license.\n","funding_links":["https://github.com/sponsors/tiangolo"],"categories":["Python","HarmonyOS","Resources","Repos","api","Web Frameworks","python3","web","Uncategorized","📦 Additional Python Libraries","Web APIs","FastAPI"],"sub_categories":["Windows Manager","Official Resources","Uncategorized","Web \u0026 APIs","Table of Content"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastapi%2Ffastapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffastapi%2Ffastapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffastapi%2Ffastapi/lists"}