written by Eric J. Ma on 2020-01-07 | tags: software development web data science
I test-drove FastAPI yesterday, and true to it's name, it's fast! And when the developers say fast, they mean it in at least two ways:
I'd like to write about the second point.
Prior to FastAPI, my development framework of choice to build a web API would have been Flask (though I will admit, I have only developed web apps, not web APIs before). My familiarity with Flask turned out to be extremely helpful for learning FastAPI: its own API tracks very closely with Flask! Many of the same idioms, including instantiating a FastAPI
object and using @app.route
decorators with string interpolation in the URIs, carry over. This is the first way that FastAPI makes API development fast: by using existing idioms.
Prior to FastAPI, I did have reservations about developing a web API using Flask because I wasn't sure how to provide sufficient documentation to API users/testers on how to use it. (Have you seen Swagger APIs without example usage documentation? Frustrating!) Turns out, FastAPI parses your docstrings to provide API docs. This means you can provide an example usage inside the routing function, and on the /docs
endpoint, all they will render on the API docs!
So in summary, FastAPI is a very productive tool to use for developing APIs. I highly recommend you check it out once you hit the appropriate opportunity!
@article{
ericmjl-2020-fastapi-apis,
author = {Eric J. Ma},
title = {FastAPI: Flask-like generator of web APIs},
year = {2020},
month = {01},
day = {07},
howpublished = {\url{https://ericmjl.github.io}},
journal = {Eric J. Ma's Blog},
url = {https://ericmjl.github.io/blog/2020/1/7/fastapi-flask-like-generator-of-web-apis},
}
I send out a newsletter with tips and tools for data scientists. Come check it out at Substack.
If you would like to sponsor the coffee that goes into making my posts, please consider GitHub Sponsors!
Finally, I do free 30-minute GenAI strategy calls for teams that are looking to leverage GenAI for maximum impact. Consider booking a call on Calendly if you're interested!