An intelligent REST API that automatically prioritizes your tasks using a smart scoring algorithm. Unlike basic todo lists, this API considers multiple factors (urgency, importance, effort, deadline proximity, and dependencies) to tell you exactly what you should work on next.
- Intelligent Priority Scoring: Automatically calculates priority scores based on multiple weighted factors
- Smart Recommendations: Suggests the next best task to work on
- Dependency Tracking: Tasks can depend on other tasks; blocked tasks get lower priority
- Deadline Awareness: Priority increases as deadlines approach
- Effort Optimization: Considers task effort in priority calculations
- Productivity Analytics: Track completion rates and performance metrics
cd task-priority-api
npm installnpm startOr for development with auto-reload:
npm run devThe API will be available at http://localhost:3000
http://localhost:3000
GET /Returns API documentation and available endpoints.
GET /api/tasks
GET /api/tasks?completed=falseQuery Parameters:
completed(optional):trueorfalseto filter by completion status
Response:
{
"count": 2,
"tasks": [
{
"id": 1,
"title": "Finish project proposal",
"description": "Complete the Q4 project proposal for client review",
"urgency": 9,
"importance": 10,
"estimatedEffort": 3,
"deadline": "2025-10-15",
"dependencies": [],
"completed": false,
"createdAt": "2025-10-11T...",
"priorityScore": 87.25,
"daysUntilDeadline": 4,
"isBlocked": false
}
]
}GET /api/tasks/priorityReturns incomplete tasks sorted by priority score (highest first).
GET /api/tasks/nextReturns the highest priority unblocked task you should work on next, plus alternatives.
Response:
{
"message": "This is your highest priority task",
"task": {
"id": 1,
"title": "Finish project proposal",
"priorityScore": 87.25,
...
},
"alternativeTasks": [...]
}GET /api/tasks/:idExample:
GET /api/tasks/1POST /api/tasks
Content-Type: application/json
{
"title": "Review code",
"description": "Review pull requests",
"urgency": 7,
"importance": 8,
"estimatedEffort": 2,
"deadline": "2025-10-13",
"dependencies": []
}Required Fields:
title(string)
Optional Fields:
description(string)urgency(number 1-10, default: 5) - How urgent is this?importance(number 1-10, default: 5) - How important is this?estimatedEffort(number 1-10, default: 5) - How much work is required?deadline(ISO date string, optional)dependencies(array of task IDs, default: [])
Response: Returns created task with priority score (201 Created)
PUT /api/tasks/:id
Content-Type: application/json
{
"title": "Updated title",
"urgency": 9,
"importance": 10
}Updates any fields provided. Fields not included remain unchanged.
PATCH /api/tasks/:id/completeMarks a task as completed and records completion timestamp.
DELETE /api/tasks/:idPermanently deletes a task.
GET /api/statsResponse:
{
"totalTasks": 10,
"completedTasks": 6,
"incompleteTasks": 4,
"overdueTasks": 1,
"highPriorityTasks": 2,
"completionRate": 60,
"averagePriorityScore": 65.5
}The priority score (0-100) is calculated using:
Priority = (Urgency ร 0.30) + (Importance ร 0.35) + (Effort ร 0.15) + (Deadline ร 0.20)
- Urgency (30% weight): How urgent is the task?
- Importance (35% weight): How important is it strategically?
- Effort (15% weight): Lower effort = higher priority (quick wins!)
- Deadline (20% weight): Closer deadlines = higher priority
- Overdue: Maximum score
- Due today: 95% score
- Due tomorrow: 90% score
- Due in 2-3 days: 70% score
- Due this week: 40% score
- Due later: 10% score
Tasks with incomplete dependencies get their priority reduced by 70% (blocked tasks).
curl -X POST http://localhost:3000/api/tasks \
-H "Content-Type: application/json" \
-d '{
"title": "Fix critical bug",
"description": "Production bug affecting users",
"urgency": 10,
"importance": 10,
"estimatedEffort": 2,
"deadline": "2025-10-12"
}'curl http://localhost:3000/api/tasks/nextcurl -X PATCH http://localhost:3000/api/tasks/1/completecurl http://localhost:3000/api/stats- Personal Productivity: Manage your daily tasks intelligently
- Team Task Management: API for building team productivity apps
- Project Planning: Track project tasks with dependencies
- Time Management: Optimize what to work on next
- Deadline Tracking: Never miss important deadlines
- Analytics: Track productivity trends over time
Potential features to add:
- User authentication & multi-user support
- Database persistence (PostgreSQL/MongoDB)
- Recurring tasks
- Task categories/tags
- Time tracking per task
- Machine learning to improve priority predictions based on your behavior
- Email/push notifications for high-priority tasks
- Integration with calendar apps
- Team collaboration features
- GraphQL endpoint
- Node.js - Runtime
- Express.js - Web framework
- CORS - Cross-origin support
- Pure JavaScript - No database required (uses in-memory storage)
MIT License - Feel free to use this in your projects!
Param Patel
Feel free to fork, improve, and submit pull requests!
Happy prioritizing! ๐ฏ