A small REST API for managing personal tasks, built with FastAPI and SQLAlchemy. Supports full CRUD, filtering by status, and ships with interactive API docs out of the box.
- Create, read, update, and delete tasks
- Filter tasks by status (
todo,in_progress,done) - SQLite persistence via SQLAlchemy (swap in Postgres/MySQL by setting
DATABASE_URL) - Auto-generated OpenAPI docs at
/docsand/redoc
git clone https://github.com/<your-username>/rest-task-api.git
cd rest-task-api
pip install -r requirements.txtRequires Python 3.9+.
uvicorn main:app --reloadThen visit:
- http://127.0.0.1:8000/docs — interactive Swagger UI
- http://127.0.0.1:8000/redoc — ReDoc documentation
# Create a task
curl -X POST http://127.0.0.1:8000/tasks \
-H "Content-Type: application/json" \
-d '{"title": "Write README", "status": "in_progress"}'
# List all tasks
curl http://127.0.0.1:8000/tasks
# List only completed tasks
curl "http://127.0.0.1:8000/tasks?status=done"
# Update a task
curl -X PATCH http://127.0.0.1:8000/tasks/1 \
-H "Content-Type: application/json" \
-d '{"status": "done"}'
# Delete a task
curl -X DELETE http://127.0.0.1:8000/tasks/1main.py FastAPI app and route handlers
models.py SQLAlchemy model + Pydantic request/response schemas
database.py SQLAlchemy engine/session setup
test_main.py Test suite (pytest + FastAPI TestClient)
pip install -r requirements.txt
pytestTests run against an isolated in-memory SQLite database, so they never touch
tasks.db.
MIT