A CRUD library API made with FastAPI used to illustrate how to code create, read, update and delete endpoints in FastAPI
The following are needed to recreate this project
- Python (3.6+)
- FastAPI
pip install fastapi
- Uvicorn
pip install uvicorn[standard]
Follow these steps to test the API on your local machine
- Navigate to your preferred directory and clone the repository
git clone https://github.com/ifeoluwafavour/fastapi-library-api
- Navigate to the library folder in the repository, create and activate a virtual environment For Windows:
python -m venv myenv
myenv\Scripts\activate.bat
For Mac OS and Linux:
python -m venv myenv
source myenv/bin/activate
- Install FastAPI and uvicorn in the virtual environment
pip install fastapi
pip install uvicorn[standard]
- Run the server for the API. A localhost address will come up for you to test the API with
uvicorn books:app --reload
- Test the API with the Swagger UI docs that was automatically generated by adding
/docs
to the localhost address like so,127.0.0.1:8000/docs
If you don't know about FastAPI, now is a good time to know about it. Here are the resources I've used so far: