A simple RESTful API built with FastAPI for managing tasks. This project demonstrates clean API design, proper HTTP methods, and modern Python development practices.
- ✅ Create, read, update, and delete tasks (CRUD operations)
- ✅ Filter tasks by completion status
- ✅ RESTful API design with proper status codes
- ✅ Input validation using Pydantic models
- ✅ Interactive API documentation (Swagger UI)
- ✅ Fast and lightweight using FastAPI
- Python 3.8+
- FastAPI - Modern web framework for building APIs
- Pydantic - Data validation using Python type hints
- Uvicorn - ASGI server
- Python 3.8 or higher
- pip (Python package manager)
- Clone the repository:
git clone https://github.com/ky-cx/task-manager-api.git
cd task-manager-api- Create a virtual environment (recommended):
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Run the application:
python main.pyThe API will be available at http://localhost:8000
Once the server is running, visit:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
| Method | Endpoint | Description |
|---|---|---|
| GET | / |
Welcome message and API overview |
| GET | /tasks |
Get all tasks |
| GET | /tasks?completed=true |
Get completed tasks |
| POST | /tasks |
Create a new task |
| GET | /tasks/{id} |
Get a specific task |
| PUT | /tasks/{id} |
Update a task |
| DELETE | /tasks/{id} |
Delete a task |
curl -X POST "http://localhost:8000/tasks" \
-H "Content-Type: application/json" \
-d '{
"title": "Learn FastAPI",
"description": "Build a REST API project",
"completed": false
}'curl -X GET "http://localhost:8000/tasks"curl -X PUT "http://localhost:8000/tasks/1" \
-H "Content-Type: application/json" \
-d '{
"title": "Learn FastAPI",
"description": "Completed the tutorial",
"completed": true
}'Once the server is running, you can test the API:
curl -X POST "http://localhost:8000/tasks" \
-H "Content-Type: application/json" \
-d '{"title": "Learn FastAPI", "description": "Complete the tutorial"}'curl http://localhost:8000/taskscurl -X PUT "http://localhost:8000/tasks/1" \
-H "Content-Type: application/json" \
-d '{"title": "Learn FastAPI", "completed": true}'API Documentation (Swagger UI)
# Run with test data
python -c "
import requests
response = requests.get('http://localhost:8000')
print(response.json())
"- Add PostgreSQL database persistence
- Implement user authentication (JWT)
- Add task categories and tags
- Deploy to Heroku/Railway
- Add unit tests with pytest
Conghui Xu
- Email: hsuconghui@gmail.com
- LinkedIn: linkedin.com/in/cx27
This project is open source and available under the MIT License.
⭐ If you find this project useful, please consider giving it a star!
