Popular dependencies in open source FastAPI projects

This is a report describing the variety of Python libraries used with FastAPI in open source projects. The repositories were sourced using GitHub code search. I analyzed requirements.txt files as the most common source of dependencies. The report includes popular packages, FastAPI versions and dependency clusters.

You can use the report to explore new libraries or pick a dependency between a few options. If you want to discover how exactly a library is used with FastAPI, use GitHub code search: fastapi {package_name} filename:requirements.txt

All repositories

This table could include any package specified in a requirements.txt file. Some packages could be depend on others, but still redundantly (or not) specified in requirements files.  

fastapi: 6483 uvicorn: 5941 pydantic: 4077
starlette: 3231 h11: 2845 click: 2776
requests: 2562 six: 2157 typing-extensions: 2128
idna: 1810 certifi: 1796 urllib3: 1723
python-multipart: 1677 chardet: 1647 numpy: 1572
aiofiles: 1365 python-dotenv: 1336 pandas: 1316
websockets: 1310 SQLAlchemy: 1203 httptools: 1148
uvloop: 1147 MarkupSafe: 1126 pytest: 1121
python-dateutil: 1104 Jinja2: 1091 gunicorn: 1079
PyYAML: 1016 pytz: 989 pyparsing: 963
toml: 877 attrs: 869 packaging: 829
colorama: 823 pycparser: 768 cffi: 767
scikit-learn: 762 dnspython: 734 passlib: 705
itsdangerous: 686 asgiref: 656 email-validator: 641
watchgod: 624 scipy: 610 Pillow: 608
greenlet: 603 joblib: 595 bcrypt: 577
pyasn1: 561 pluggy: 550 py: 548
rsa: 531 matplotlib: 524 pymongo: 504
async-generator: 503 cryptography: 498 psycopg2-binary: 491
python-jose: 480 wrapt: 469 sqlalchemy: 467
Werkzeug: 451 ujson: 443 wcwidth: 433
psycopg2: 429 zipp: 428 jinja2: 428
iniconfig: 421 alembic: 417 importlib-metadata: 416
black: 409 tqdm: 408 protobuf: 405
aniso8601: 404 appdirs: 402 PyJWT: 400
beautifulsoup4: 397 graphene: 393 mccabe: 388
regex: 380 async-exit-stack: 380 promise: 379
graphql-core: 366 decorator: 364 graphql-relay: 364
orjson: 361 prompt-toolkit: 354 httpx: 353
cachetools: 352 pycodestyle: 348 flake8: 342

The full list formatted with one library on each row.

FastAPI versions

0.10.1: 2 0.10.2: 1 0.11.0: 1
0.12.1: 1 0.13.0: 3 0.2.0: 1
0.20.0: 4 0.27.0: 1 0.28.0: 1
0.29.0: 4 0.29.1: 3 0.30.0: 2
0.31.0: 2 0.33.0: 14 0.35.0: 12
0.38.1: 18 0.39.0: 3 0.42.0: 23
0.43.0: 2 0.44.0: 12 0.44.1: 9
0.45.0: 27 0.46.0: 10 0.47: 2
0.47.0: 1 0.47.1: 53 0.48.0: 15
0.49.0: 13 0.49.2: 1 0.5.4: 1
0.50.0: 1 0.51.0: 2 0.52.0: 73
0.53: 1 0.53.0: 7 0.53.1: 5
0.53.2: 18 0.54: 3 0.54.0: 12
0.54.1: 78 0.54.2: 17 0.55: 1
0.55.0: 2 0.55.1: 31 0.56.0: 2
0.56.1: 1 0.57.0: 5 0.58: 1
0.58.0: 26 0.58.1: 39 0.59: 1
0.59.0: 23 0.6.1: 1 0.60: 1
0.60.0: 12 0.60.00: 1 0.60.1: 57
0.60.2: 7 0.61: 1 0.61.0: 41
0.61.1: 406 0.61.2: 228 0.62.0: 301
0.63: 7 0.63.0: 1569 0.64: 1
0.64.0: 56 0.65: 4 0.65.0: 32
0.65.1: 535 0.65.2: 616 0.65.3: 19
0.66: 2 0.66.0: 238 0.66.1: 25
0.67.0: 23 0.68.0: 8 0.8.0: 2

Clusters

For a few selected packages I collected libraries that developers commonly use together with the source package. The percent is calculated as the number of intersections in requirements.txt files between source and target packages divided by number of occurrences of the target package.

bs4 scikit-learn ecdsa graphene
soupsieve: 36.4% threadpoolctl: 98.9% python-jose: 52.3% graphql-relay: 100%
beautifulsoup4: 29.0% s3fs: 97.2% rsa: 48.5% graphql-core: 98.6%
selenium: 25.4% gcsfs: 96.6% pyasn1: 46.2% Rx: 97.9%
lxml: 23.9% memoized-property: 96.3% bcrypt: 34.6% promise: 96.3%
html5lib: 22.3% mlflow: 89.6% cryptography: 31.9% aniso8601: 89.4%
xlrd: 18.3% dill: 88.2% passlib: 31.4% orjson: 82.3%
zope.interface: 17.6% twine: 86.7% pycparser: 29.6% async-exit-stack: 80.4%
sqlparse: 17.3% joblib: 82.6% cffi: 29.5% ujson: 71.6%
QtPy: 17.0% yapf: 79.0% python-editor: 25.2% async-generator: 61.8%
Django: 16.8% seaborn: 77.0% Mako: 23.7% email-validator: 50.3%
tzlocal: 15.2% ipywidgets: 74.1% greenlet: 19.7% itsdangerous: 48.4%
Babel: 15.2% scipy: 73.9% alembic: 17.1% dnspython: 43.9%
networkx: 15.0% google-cloud-storage: 71.7% email-validator: 16.0% watchgod: 36.9%
widgetsnbextension: 14.0% widgetsnbextension: 71.3% dnspython: 15.7% PyYAML: 29.8%
docutils: 13.9% termcolor: 71.3% PyMySQL: 15.0% MarkupSafe: 27.2%
websocket-client: 13.6% Send2Trash: 71.2% SQLAlchemy: 14.8% Jinja2: 27.0%
defusedxml: 13.2% notebook: 71.0% pycodestyle: 14.8% websockets: 25.3%
plotly: 13.2% pip: 70.5% httpcore: 14.1% aiofiles: 23.8%
filelock: 12.8% nbconvert: 69.6% asyncpg: 14.0% atomicwrites: 22.4%
nltk: 12.7% sklearn: 69.3% botocore: 14.0% chardet: 20.4%
requests-oauthlib: 12.7% pandocfilters: 69.2% autopep8: 14.0% pathspec: 20.3%
ipywidgets: 12.6% terminado: 69.1% zope.interface: 13.7% mypy-extensions: 20.2%
terminado: 12.6% testpath: 69.0% iniconfig: 13.7% urllib3: 19.8%
webencodings: 12.5% mistune: 68.7% s3transfer: 13.7% python-dotenv: 19.7%
oauthlib: 12.4% wheel: 68.2% text-unidecode: 13.4% python-multipart: 19.6%

pip-compile files

Some of the projects had their requirements composed with pip-compile. I decided to analyze such files separately: this way I get to group dependencies on direct and indirect (dependencies of other dependencies).

Direct dependencies

Library Occurrences
Total repositories 95
fastapi 95
uvicorn 72
pydantic 69
starlette 66
typing-extensions 59
click 51
h11 46
certifi 46
python-dotenv 40
six 39
urllib3 39
idna 34
requests 30
pyyaml 28
chardet 26
gunicorn 25
python-multipart 25
websockets 24
uvloop 23
sqlalchemy 22
httptools 21
cffi 21
pycparser 21
markupsafe 20
attrs 20

Indirect dependencies


Library Occurrences
Total repositories 95
fastapi 95
pydantic 95
starlette 95
click 74
h11 73
uvicorn 72
typing-extensions 68
certifi 65
six 62
urllib3 59
idna 55
chardet 46
python-dotenv 43
requests 42
websockets 42
httptools 40
uvloop 40
pyyaml 36
attrs 35
python-dateutil 32
cffi 32
pycparser 32
markupsafe 30
python-multipart 27
gunicorn 25

FastAPI versions

Version Occurrences
0.23.0 1
0.33.0 2
0.34.0 1
0.38.1 1
0.42.0 2
0.45.0 1
0.48.0 1
0.52.0 2
0.54.1 2
0.55.1 1
0.60.1 1
0.61.0 3
0.61.1 14
0.61.2 2
0.63.0 17
0.64.0 2
0.65.1 25
0.65.2 13
0.66.0 2
0.67.0 1
0.68.0 1



Notes

Did you know the specification for a line in requirements.txt goes much further than the common usage? From PEP 808:

All features of the language shown with a name based lookup:

requests [security,tests] >= 2.8.1, == 2.8.* ; python_version < "2.7"


GitHub Search API allows to extract only first 1,000 results for each search query, so I had to get creative with file size qualifier to iterate over all results:

Query 1: fastapi filename:requirements.txt size:1..16

Query 2: fastapi filename:{filename} size:17..32

etc.