Todos API

Manage todo tasks and checklists with our comprehensive Todos API.

Overview

The Todos API provides endpoints for managing todo tasks, including creation, completion tracking, and user-specific task lists. Each todo belongs to a user and can be marked as completed.

Base URL: /api/todos

Endpoints

GET/api/todos

Get all todos with optional filtering and pagination

POST/api/todos

Create a new todo

GET/api/todos/:id

Get a specific todo by ID

PUT/api/todos/:id

Update a specific todo

DELETE/api/todos/:id

Delete a specific todo

Query Parameters

userIdFilter todos by user ID
completedFilter by completion status (true/false)
qSearch todos by title
limitNumber of todos to return (default: 10)
offsetNumber of todos to skip (default: 0)

Response Format

List Response

{
  "total": 50,
  "limit": 10,
  "offset": 0,
  "results": [
    {
      "id": 1,
      "userId": 1,
      "title": "delectus aut autem",
      "completed": false
    }
  ]
}

Single Todo Response

{
  "id": 1,
  "userId": 1,
  "title": "delectus aut autem",
  "completed": false
}

Required Fields

When creating or updating a todo, the following fields are required:

  • userId - The ID of the user this todo belongs to
  • title - The title/description of the todo task

Optional fields:

  • completed - Whether the todo is completed (default: false)

Todo Structure

id - Unique identifier for the todo
userId - ID of the user who owns this todo
title - Title or description of the todo task
completed - Boolean indicating if the todo is completed

Common Todo Statuses

completed: false - Task is pending or in progress
completed: true - Task has been completed

Usage Examples

Get Todos by User

// Get all todos for user 1
fetch('/api/todos?userId=1')
  .then(response => response.json())
  .then(data => console.log(data.results));

Get Completed Todos

// Get all completed todos
fetch('/api/todos?completed=true')
  .then(response => response.json())
  .then(data => console.log(data.results));

Create New Todo

// Add a new todo for user 1
fetch('/api/todos', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    userId: 1,
    title: "Buy groceries",
    completed: false
  })
})
.then(response => response.json())
.then(data => console.log(data));

Mark Todo as Completed

// Mark todo 1 as completed
fetch('/api/todos/1', {
  method: 'PUT',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    userId: 1,
    title: "Buy groceries",
    completed: true
  })
})
.then(response => response.json())
.then(data => console.log(data));

Search Todos

// Search todos by title
fetch('/api/todos?q=grocery&limit=5')
  .then(response => response.json())
  .then(data => console.log(data.results));

⚠️ Important Note

All data changes (POST, PUT, DELETE) are stored in memory and will be reset when the server restarts. This is a mock API designed for development and testing purposes.

ResponseRift JSON API • Production-Ready, Zero-Config