This document provides comprehensive information about the RESTful API endpoints, request/response formats, and integration guidelines for the Todo List application.
Local Development: http://localhost:3001
API Base Path: /api
Currently, the API does not require authentication. All endpoints are publicly accessible during development.
Future Implementation: JWT-based authentication will be added for user-specific data protection.
- Tasks: Core task management operations
- Categories: Category management for task organization
- Health: System health and status checks
- Export: Data export functionality (planned)
- Share: Task sharing features (planned)
All API responses follow a consistent JSON format:
{
"success": true,
"data": {...},
"message": "Operation completed successfully",
"timestamp": "2025-07-31T12:00:00.000Z"
}Error responses include detailed information:
{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Task title is required",
"details": {...}
},
"timestamp": "2025-07-31T12:00:00.000Z"
}Retrieve tasks with optional filtering and search.
| Parameter | Type | Description | Example |
|---|---|---|---|
search |
string | Search in title, description, tags | ?search=meeting |
category |
integer | Filter by category ID | ?category=1 |
priority |
string | Filter by priority level | ?priority=high |
completed |
boolean | Filter by completion status | ?completed=false |
overdue |
boolean | Filter overdue tasks | ?overdue=true |
limit |
integer | Number of results (default: 100) | ?limit=20 |
offset |
integer | Pagination offset | ?offset=20 |
GET /api/tasks?search=project&priority=high&completed=false{
"success": true,
"data": [
{
"id": 1,
"title": "Complete project documentation",
"description": "Write comprehensive API documentation",
"priority": "high",
"is_completed": false,
"due_date": "2025-08-05T10:00:00.000Z",
"order_index": 0,
"tags": ["documentation", "project"],
"category_id": 2,
"created_at": "2025-07-31T08:00:00.000Z",
"updated_at": "2025-07-31T08:00:00.000Z",
"category": {
"id": 2,
"name": "Work",
"color": "#10B981"
}
}
],
"message": "Tasks retrieved successfully",
"total": 1,
"timestamp": "2025-07-31T12:00:00.000Z"
}Create a new task.
{
"title": "Complete project documentation",
"description": "Write comprehensive API documentation",
"priority": "high",
"due_date": "2025-08-05T10:00:00.000Z",
"category_id": 2,
"tags": ["documentation", "project"]
}title(string): Task title (1-255 characters)
description(string): Task descriptionpriority(string): Priority level (high,medium,low)due_date(string): ISO 8601 date stringcategory_id(integer): Valid category IDtags(array): Array of string tags
{
"success": true,
"data": {
"id": 15,
"title": "Complete project documentation",
"description": "Write comprehensive API documentation",
"priority": "high",
"is_completed": false,
"due_date": "2025-08-05T10:00:00.000Z",
"order_index": 14,
"tags": ["documentation", "project"],
"category_id": 2,
"created_at": "2025-07-31T12:00:00.000Z",
"updated_at": "2025-07-31T12:00:00.000Z"
},
"message": "Task created successfully",
"timestamp": "2025-07-31T12:00:00.000Z"
}Update an existing task.
id(integer): Task ID
Same as POST /api/tasks, but all fields are optional.
{
"success": true,
"data": {
"id": 15,
"title": "Updated task title",
"description": "Updated description",
"priority": "medium",
"is_completed": false,
"due_date": "2025-08-10T10:00:00.000Z",
"order_index": 14,
"tags": ["updated", "task"],
"category_id": 1,
"created_at": "2025-07-31T12:00:00.000Z",
"updated_at": "2025-07-31T12:30:00.000Z"
},
"message": "Task updated successfully",
"timestamp": "2025-07-31T12:30:00.000Z"
}Delete a task.
id(integer): Task ID
{
"success": true,
"data": null,
"message": "Task deleted successfully",
"timestamp": "2025-07-31T12:35:00.000Z"
}Toggle task completion status.
id(integer): Task ID
{
"is_completed": true
}{
"success": true,
"data": {
"id": 15,
"title": "Complete project documentation",
"is_completed": true,
"updated_at": "2025-07-31T12:40:00.000Z"
},
"message": "Task completion status updated",
"timestamp": "2025-07-31T12:40:00.000Z"
}Reorder multiple tasks (for drag & drop functionality).
{
"tasks": [
{"id": 1, "order_index": 0},
{"id": 3, "order_index": 1},
{"id": 2, "order_index": 2}
]
}{
"success": true,
"data": [
{"id": 1, "order_index": 0, "updated_at": "2025-07-31T12:45:00.000Z"},
{"id": 3, "order_index": 1, "updated_at": "2025-07-31T12:45:00.000Z"},
{"id": 2, "order_index": 2, "updated_at": "2025-07-31T12:45:00.000Z"}
],
"message": "Tasks reordered successfully",
"timestamp": "2025-07-31T12:45:00.000Z"
}Retrieve all categories.
{
"success": true,
"data": [
{
"id": 1,
"name": "Personal",
"color": "#3B82F6",
"created_at": "2025-07-31T08:00:00.000Z",
"updated_at": "2025-07-31T08:00:00.000Z"
},
{
"id": 2,
"name": "Work",
"color": "#10B981",
"created_at": "2025-07-31T08:00:00.000Z",
"updated_at": "2025-07-31T08:00:00.000Z"
}
],
"message": "Categories retrieved successfully",
"timestamp": "2025-07-31T12:00:00.000Z"
}Create a new category.
{
"name": "Project Tasks",
"color": "#8B5CF6"
}name(string): Category name (1-100 characters, unique)
color(string): Hex color code (default: #3B82F6)
{
"success": true,
"data": {
"id": 5,
"name": "Project Tasks",
"color": "#8B5CF6",
"created_at": "2025-07-31T12:50:00.000Z",
"updated_at": "2025-07-31T12:50:00.000Z"
},
"message": "Category created successfully",
"timestamp": "2025-07-31T12:50:00.000Z"
}Update an existing category.
id(integer): Category ID
{
"name": "Updated Category Name",
"color": "#F59E0B"
}{
"success": true,
"data": {
"id": 5,
"name": "Updated Category Name",
"color": "#F59E0B",
"created_at": "2025-07-31T12:50:00.000Z",
"updated_at": "2025-07-31T12:55:00.000Z"
},
"message": "Category updated successfully",
"timestamp": "2025-07-31T12:55:00.000Z"
}Delete a category. Tasks in this category will have their category_id set to null.
id(integer): Category ID
{
"success": true,
"data": null,
"message": "Category deleted successfully",
"timestamp": "2025-07-31T13:00:00.000Z"
}Check system health and status.
{
"status": "OK",
"timestamp": "2025-07-31T13:05:00.000Z",
"uptime": "2h 30m 45s",
"version": "1.0.0"
}Test database connectivity.
{
"success": true,
"message": "Database connected successfully",
"timestamp": "2025-07-31T13:05:00.000Z"
}Get API usage statistics.
{
"success": true,
"data": {
"total_tasks": 25,
"completed_tasks": 15,
"active_tasks": 10,
"total_categories": 4,
"overdue_tasks": 2
},
"message": "Statistics retrieved successfully",
"timestamp": "2025-07-31T13:05:00.000Z"
}Export tasks in various formats.
Planned Query Parameters:
format: Export format (json,csv,pdf)filter: Apply current filters to exportdate_range: Export tasks within date range
Create a shareable link for tasks.
Planned Request Body:
{
"task_ids": [1, 2, 3],
"expires_in": "7d",
"password": "optional_password"
}Access shared task list.
Planned Response:
- Read-only task data
- Share metadata
- Access logging
| Code | Description | When Used |
|---|---|---|
| 200 | OK | Successful GET, PUT, PATCH |
| 201 | Created | Successful POST |
| 204 | No Content | Successful DELETE |
| 400 | Bad Request | Invalid request data |
| 404 | Not Found | Resource doesn't exist |
| 422 | Unprocessable Entity | Validation errors |
| 500 | Internal Server Error | Server errors |
{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Task title is required",
"details": {
"field": "title",
"value": "",
"constraint": "required"
}
},
"timestamp": "2025-07-31T13:10:00.000Z"
}{
"success": false,
"error": {
"code": "NOT_FOUND",
"message": "Task not found",
"details": {
"resource": "task",
"id": 999
}
},
"timestamp": "2025-07-31T13:10:00.000Z"
}{
"success": false,
"error": {
"code": "INTERNAL_ERROR",
"message": "An unexpected error occurred",
"details": null
},
"timestamp": "2025-07-31T13:10:00.000Z"
}// Get all tasks
const response = await fetch('http://localhost:3001/api/tasks');
const data = await response.json();
// Create a task
const newTask = await fetch('http://localhost:3001/api/tasks', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
title: 'New Task',
priority: 'high',
category_id: 1
})
});
// Update task completion
const updatedTask = await fetch(`http://localhost:3001/api/tasks/1/complete`, {
method: 'PATCH',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
is_completed: true
})
});import axios from 'axios';
const api = axios.create({
baseURL: 'http://localhost:3001/api',
headers: {
'Content-Type': 'application/json',
}
});
// Get filtered tasks
const tasks = await api.get('/tasks', {
params: {
search: 'project',
priority: 'high',
completed: false
}
});
// Create category
const category = await api.post('/categories', {
name: 'New Category',
color: '#FF5733'
});
// Delete task
await api.delete('/tasks/1');# Get all tasks
curl -X GET "http://localhost:3001/api/tasks"
# Create task
curl -X POST "http://localhost:3001/api/tasks" \
-H "Content-Type: application/json" \
-d '{
"title": "New Task",
"description": "Task description",
"priority": "high",
"category_id": 1
}'
# Update task
curl -X PUT "http://localhost:3001/api/tasks/1" \
-H "Content-Type: application/json" \
-d '{
"title": "Updated Task Title",
"priority": "medium"
}'
# Delete task
curl -X DELETE "http://localhost:3001/api/tasks/1"
# Toggle completion
curl -X PATCH "http://localhost:3001/api/tasks/1/complete" \
-H "Content-Type: application/json" \
-d '{"is_completed": true}'- CORS: Configured for development origins
- Input Validation: Server-side validation for all inputs
- SQL Injection Prevention: Parameterized queries
- Error Handling: No sensitive information in error responses
- Authentication: JWT-based user authentication
- Authorization: Role-based access control
- Rate Limiting: API request throttling
- Input Sanitization: Advanced input cleaning
- HTTPS: Secure transport in production
- GET /api/tasks: < 100ms (typical)
- POST /api/tasks: < 200ms (typical)
- PUT /api/tasks/:id: < 150ms (typical)
- DELETE /api/tasks/:id: < 100ms (typical)
- Database Indexes: Optimized query performance
- Query Optimization: Efficient SQL queries
- Pagination: Large dataset handling
- Caching: Response caching (planned)
- Thunder Client (VS Code extension)
- Postman collection available
- cURL commands provided
- Automated tests (planned)
Sample tasks and categories are automatically created during database setup. See SETUP.md for initialization details.
The API is designed to work seamlessly with the React frontend. For frontend implementation details, see FEATURES.md.
// taskService.js example
export const taskService = {
async getAllTasks(filters = {}) {
const params = new URLSearchParams(filters);
const response = await api.get(`/tasks?${params}`);
return response.data;
},
async createTask(taskData) {
const response = await api.post('/tasks', taskData);
return response.data;
}
// ... other methods
};- API Version: 1.0
- Endpoint Versioning: Not implemented (future consideration)
- Backward Compatibility: Maintained within major versions
- Semantic Versioning: Major.Minor.Patch
- Deprecation Notices: 6-month notice period
- Migration Guides: Provided for breaking changes
📝 Note: This API is currently in development. Endpoints marked as "Planned" are part of the Phase 3 roadmap and subject to change.
For setup instructions, see SETUP.md.
For feature details, see FEATURES.md.
For project overview, see README.md.