A simple but professionally structured RESTful API for a "To-Do" list, built with Python and FastAPI.
This project was built to demonstrate best practices in modern API design, including:
- Separation of Concerns: Logic, models, and the app entrypoint are in separate files (routes.py,models.py,main.py).
- Data Validation: Uses Pydantic models to validate incoming data.
- Auto-Documentation: Generates interactive API docs at the /docsendpoint.
- Python 3
- FastAPI
- Uvicorn (ASGI Server)
- 
Clone the repo: git clone https://github.com/justknuth/fastapi-todo-api.git cd fastapi-todo-api
- 
Change directory to the apifolder:cd api
- 
Create a virtual environment: python -m venv venv 
- 
Activate the virtual environment: - On macOS/Linux (Bash):
source venv/bin/activate
- On Windows (PowerShell):
.\venv\Scripts\activate 
 
- On macOS/Linux (Bash):
- 
Install dependencies: pip install -r requirements.txt 
- 
Run the app: uvicorn main:app --reload (You should see a message like: Uvicorn running on http://127.0.0.1:8000)
- 
Test the API: - Open your web browser and go to http://127.0.0.1:8000/docs.
- This is an interactive documentation page for your API.
- Expand the POST /todosendpoint, click "Try it out", and create a new to-do by pasting this into the request body:{ "task": "Finish my GitHub portfolio" }
- Click "Execute". You'll see a 201response.
- Now, expand the GET /todosendpoint, click "Try it out", and click "Execute". You will see the to-do you just created in the response.
 
- Open your web browser and go to