Skip to main content
GET
/
api
/
tasks
Get All Tasks
curl --request GET \
  --url https://api.example.com/api/tasks
{
  "response": [
    {}
  ]
}

Endpoint

GET /api/tasks
Retrieves all tasks from the database. Returns an array of task objects including their IDs, titles, descriptions, completion status, category assignments, and timestamps.

Query Parameters

Currently, this endpoint does not support query parameters for filtering, sorting, or pagination. All tasks are returned in a single response.
The source code includes a TODO comment indicating future support for filtering by categoryId and other parameters.

Response

response
array
An array of Task objects. Returns an empty array [] if no tasks exist.

Status Codes

  • 200 OK - Successfully retrieved all tasks

Examples

curl http://localhost:3000/api/tasks

Response Example

[
  {
    "_id": "550e8400-e29b-41d4-a716-446655440000",
    "title": "Write API documentation",
    "description": "Create comprehensive docs",
    "completed": true,
    "categoryId": "a1b2c3d4-e5f6-4a5b-8c9d-0e1f2a3b4c5d",
    "createdAt": "2026-03-11T10:00:00.000Z",
    "updatedAt": "2026-03-11T16:00:00.000Z",
    "finishedAt": "2026-03-11T16:00:00.000Z"
  },
  {
    "_id": "d4c3b2a1-0f1e-4d3c-9b8a-7c6b5a4d3e2f",
    "title": "Review pull request",
    "description": "Check code quality",
    "completed": false,
    "categoryId": "uncategorized",
    "createdAt": "2026-03-11T12:00:00.000Z",
    "updatedAt": "2026-03-11T12:00:00.000Z"
  },
  {
    "_id": "f1e2d3c4-b5a6-4978-8c9d-0a1b2c3d4e5f",
    "title": "Buy groceries",
    "completed": false,
    "categoryId": "b2c3d4e5-f6a7-4b8c-9d0e-1f2a3b4c5d6e",
    "createdAt": "2026-03-11T14:00:00.000Z"
  }
]

Usage Notes

Performance Consideration: Since this endpoint returns all tasks without pagination, be aware of performance implications if your application manages a large number of tasks.
To filter tasks by category on the client side:
const tasks = await fetch('http://localhost:3000/api/tasks').then(r => r.json());
const workTasks = tasks.filter(task => task.categoryId === 'your-category-uuid');
const uncategorizedTasks = tasks.filter(task => task.categoryId === 'uncategorized');

Common Use Cases

Get All Completed Tasks

const response = await fetch('http://localhost:3000/api/tasks');
const tasks = await response.json();
const completed = tasks.filter(task => task.completed === true);

Get Tasks by Category

const response = await fetch('http://localhost:3000/api/tasks');
const tasks = await response.json();
const categoryTasks = tasks.filter(task => 
  task.categoryId === '550e8400-e29b-41d4-a716-446655440000'
);

Sort Tasks by Creation Date

const response = await fetch('http://localhost:3000/api/tasks');
const tasks = await response.json();
tasks.sort((a, b) => new Date(b.createdAt) - new Date(a.createdAt));

Build docs developers (and LLMs) love