fastapi/fastapi
By the numbers
Data collected on 2026-04-30 from the master branch (commit d8a2c1eda).
Codebase size
| Area | Python files | Lines of code |
|---|---|---|
Framework (fastapi/) |
48 | 19,335 |
Tests (tests/) |
581 | 74,543 |
Doc examples (docs_src/) |
454 | 8,556 |
The framework is small. The repo is large because tutorials and translations live alongside it. The Markdown content under docs/ totals 1,518 files across 14 languages.
xychart-beta horizontal
title "Lines of code by area"
x-axis ["fastapi/", "docs_src/", "tests/"]
y-axis "Lines"
bar [19335, 8556, 74543]Largest source files in fastapi/
| File | Lines | What lives there |
|---|---|---|
fastapi/routing.py |
4,956 | APIRouter, APIRoute, APIWebSocketRoute, request/response wrappers, response serialization |
fastapi/applications.py |
4,691 | The FastAPI class — the entrypoint user code instantiates |
fastapi/param_functions.py |
2,461 | Functional wrappers for Path, Query, Header, Cookie, Body, Form, File, Depends, Security |
fastapi/dependencies/utils.py |
1,057 | solve_dependencies, get_dependant, body-field flattening, request parsing |
fastapi/params.py |
755 | Param, Body, Form, File, Depends, Security FieldInfo subclasses |
fastapi/security/oauth2.py |
693 | OAuth2PasswordBearer, OAuth2AuthorizationCodeBearer, OAuth2PasswordRequestForm, SecurityScopes |
fastapi/openapi/utils.py |
606 | get_openapi() schema generator |
These six files carry the bulk of the framework's logic. Everything else is either a thin Starlette/Pydantic shim, a security scheme, or supporting glue.
Tests
- 581 test files; 74,543 lines.
- Three groups: framework unit tests (
tests/test_*.py), tutorial replays (tests/test_tutorial/, 77 sub-directories mirroringdocs_src/), and benchmarks (tests/benchmarks/). - The largest single file is
tests/test_include_router_defaults_overrides.pyat 394,863 lines — it is generated to enumerate router-inclusion cases. The next-largest,tests/test_generate_unique_id_function.py, is 76,760 lines. pytest -n auto --dist loadgroup(seescripts/test.sh) parallelises across cores.pyproject.tomlenforcesfilterwarnings = ["error"].
Activity
| Window | Commits |
|---|---|
| Last 90 days | 523 |
| 2026 (year-to-date) | 597 |
| 2025 | 1,144 |
| 2024 | 1,999 |
| 2023 | 780 |
| 2022 | 665 |
| 2021 | 482 |
| 2020 | 725 |
| 2019 | 2,193 |
| All time | 7,100 |
xychart-beta
title "Commits per year"
x-axis ["2019", "2020", "2021", "2022", "2023", "2024", "2025", "2026 YTD"]
y-axis "Commits"
bar [2193, 725, 482, 665, 780, 1999, 1144, 597]2024 was the highest-activity year on record, driven heavily by automated maintenance commits.
Bot-attributed commits
Counting authors whose name ends in [bot]:
- 540 commits (≈ 7.6% of all commits) carry an explicit bot author.
- The leading bots in the most recent 200 commits are
github-actions[bot](97) anddependabot[bot](40).github-actions[bot]runs the release-notes update, sponsor regeneration, contributor refresh, and translation workflows;dependabot[bot]keeps the lockfile current. - This is a lower bound — AI-assisted edits made by humans through normal commit flows leave no trace in git history.
Cross-cutting
- TODO/FIXME/HACK comments in
fastapi/: 15. Almost all are short notes about Pydantic-version edge cases. - Workspace dependencies (
pyproject.toml [project.dependencies]): 5 runtime dependencies (starlette,pydantic,typing-extensions,typing-inspection,annotated-doc). Thestandardextra addsfastapi-cli,httpx,jinja2,python-multipart,email-validator,uvicorn[standard],pydantic-settings,pydantic-extra-types. - Optional dependency groups declared in
pyproject.toml: 4 (standard,standard-no-fastapi-cloud-cli,all, plus the devdependency-groups).
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.
Previous
Glossary
Next
Lore