A simple RESTful API built with FastAPI for managing tasks. This application is designed for testing debugging capabilities with LLMs.
- Create, read, update, and delete tasks
- Filter tasks by completion status
- Filter tasks by priority level (1-5)
- Get task statistics
- Pagination support
- Input validation
- Clone this repository
- Install dependencies:
pip install -r requirements.txt
python main.py
Or using uvicorn directly:
uvicorn main:app --reload
The API will be available at http://localhost:8000
Once the application is running, you can access:
- Interactive API docs:
http://localhost:8000/docs
- Alternative API docs:
http://localhost:8000/redoc
curl http://localhost:8000/
curl -X POST http://localhost:8000/tasks \
-H "Content-Type: application/json" \
-d '{
"title": "Complete project documentation",
"description": "Write comprehensive docs for the API",
"priority": 3
}'
# Get all tasks
curl http://localhost:8000/tasks
# Get completed tasks only
curl http://localhost:8000/tasks?completed=true
# Get pending tasks only
curl http://localhost:8000/tasks?completed=false
# Pagination
curl http://localhost:8000/tasks?skip=0&limit=10
# Replace {task_id} with actual task ID
curl http://localhost:8000/tasks/{task_id}
# Partial update (only update specified fields)
curl -X PUT http://localhost:8000/tasks/{task_id} \
-H "Content-Type: application/json" \
-d '{
"completed": true,
"priority": 5
}'
# Update title
curl -X PUT http://localhost:8000/tasks/{task_id} \
-H "Content-Type: application/json" \
-d '{
"title": "Updated task title"
}'
curl -X DELETE http://localhost:8000/tasks/{task_id}
# Get all priority 5 tasks
curl http://localhost:8000/tasks/priority/5
# Get all priority 1 tasks
curl http://localhost:8000/tasks/priority/1
curl http://localhost:8000/stats
Here's a complete example workflow:
# 1. Create a high-priority task
TASK_ID=$(curl -s -X POST http://localhost:8000/tasks \
-H "Content-Type: application/json" \
-d '{
"title": "Fix critical bug",
"description": "Memory leak in production",
"priority": 5
}' | python3 -c "import sys, json; print(json.load(sys.stdin)['id'])")
echo "Created task with ID: $TASK_ID"
# 2. Create a normal priority task
curl -X POST http://localhost:8000/tasks \
-H "Content-Type: application/json" \
-d '{
"title": "Update documentation",
"description": "Add API examples",
"priority": 2
}'
# 3. List all tasks
curl http://localhost:8000/tasks | python3 -m json.tool
# 4. Mark the critical task as completed
curl -X PUT http://localhost:8000/tasks/$TASK_ID \
-H "Content-Type: application/json" \
-d '{
"completed": true
}'
# 5. Get statistics
curl http://localhost:8000/stats | python3 -m json.tool
# 6. Get only high-priority tasks
curl http://localhost:8000/tasks/priority/5 | python3 -m json.tool
{
"id": "string (UUID)",
"title": "string (required, 1-100 chars)",
"description": "string (optional, max 500 chars)",
"completed": "boolean (default: false)",
"priority": "integer (1-5, default: 1)",
"created_at": "datetime",
"updated_at": "datetime"
}
- 1: Very Low
- 2: Low
- 3: Medium
- 4: High
- 5: Critical
{
"id": "123e4567-e89b-12d3-a456-426614174000",
"title": "Complete project documentation",
"description": "Write comprehensive docs for the API",
"completed": false,
"priority": 3,
"created_at": "2024-01-14T10:30:00",
"updated_at": "2024-01-14T10:30:00"
}
{
"detail": "Task with id '123e4567-e89b-12d3-a456-426614174000' not found"
}
{
"detail": "Priority must be between 1 and 5"
}