A simple and efficient Todo List API built with FastAPI, featuring full CRUD operations for managing your tasks.
- ✅ Create new todos
- 📝 Read/List all todos
- ✏️ Update existing todos
- 🗑️ Delete todos
- 🚀 Fast and lightweight API
- 📚 Interactive API documentation (Swagger UI)
TodoList/
├── main.py # FastAPI application entry point
├── data/
│ └── fake_db.py # In-memory database simulation
├── models/
│ └── todo.py # Todo data models
├── routers/
│ └── todo.py # Todo API routes
└── requirements.txt # Project dependencies
-
Clone the repository
git clone https://github.com/alifallahrn/fastapi-todolist.git cd fastapi-todolist -
Create a virtual environment
python -m venv venv
-
Activate the virtual environment
- Windows:
venv\Scripts\activate
- macOS/Linux:
source venv/bin/activate
- Windows:
-
Install dependencies
pip install fastapi uvicorn
-
Start the development server
uvicorn main:app --reload
-
Access the application
- API Base URL: http://localhost:8000
- Interactive API Documentation: http://localhost:8000/docs
- Alternative API Documentation: http://localhost:8000/redoc
| Method | Endpoint | Description |
|---|---|---|
| GET | /todos |
Get all todos |
| GET | /todos/{todo_id} |
Get a specific todo |
| POST | /todos |
Create a new todo |
| DELETE | /todos/{todo_id} |
Delete a todo |
curl -X POST "http://localhost:8000/todos" \
-H "Content-Type: application/json" \
-d '{"task": "Learn FastAPI", "completed": false}'curl -X GET "http://localhost:8000/todos"curl -X DELETE "http://localhost:8000/todos/1"The Todo model includes:
id: Unique identifier (auto-generated)task: Todo title (required)completed: Completion status (default: false)
- FastAPI: Modern, fast web framework for building APIs
- Python 3.7+: Programming language
- Pydantic: Data validation using Python type annotations
- Uvicorn: ASGI server for running the application
uvicorn main:app --reload --host 127.0.0.1 --port 8000Ali Fallah
- GitHub: @alifallahrn
⭐ If you found this project helpful, please give it a star!