First part of this talk should be covering why FastAPI may suit your product needs.
- Easy/quick development. Get to market faster. Spend less time messing with boilerplate code.
- It's the fastest Python API framework out there, beating Django/Flask.
- No Postman required! FastAPI is standards-based, with a built-in OpenAPI platform (localhost:8000/docs) you can test your endpoints right away.
- Great documentation (https://fastapi.tiangolo.com/)
- Fast growing community (50K+ stars - 21/Oct/22)
- Simple testing
- What can it do? Type your request payloads, GET/POST/PATCH/DELETE endpoints, Path/Query parameters, ...
- What can't it do? (https://dev.to/fuadrafid/fastapi-the-good-the-bad-and-the-ugly-20ob, https://www.netguru.com/blog/python-flask-versus-fastapi)
We use this endpoint to fetch data
We use this endpoint to send complete data
We use this endpoint to delete data
We use this endpoint to update data
You can think of these parameters as required parameters for the endpoint e.g.
You can think of this parameter as an optional parameter which we can use to filter payloads. Some common query parameters are: page/size/sort.
(I am assuming you already have an active Python dev environment w/ at least Python 3.10.6)
- Clone this repository
- Open the cloned repository in VSCode or you preferred IDE.
- View setup.md for installation guide
What got installed? FastAPI - A Web Framework for quickly creating APIs, Unicorn - an ASGI server
⚠️ ATTENTION⚠️ If you get lost at any point or would like to jump ahead you can view the Resource folder inside the cloned repository. It will have a completed copy of what we're about done to in this tutorial.
From your IDE create a file called tutorial.py.
Open your web browser and navigate to: localhost:8000/docs. If you followed the steps correctly you will notice the "read root" endpoint. Now let's test it.