Todolist API

Create a simple todo Rest API with features to add, complete, and delete tasks.

1 hour
easy
76 submissions

Project Overview

Create a simple todo Rest API with features to add, complete, and delete tasks.

The TodoList API Project is a comprehensive, hands-on API development and testing project. This project involves building a RESTful API that handles basic task management operations for a to-do list application. Through implementing this API, developers will learn how to design, implement, and test various endpoints to manage tasks effectively.

Your submissions

No submissions yet, start by making your first submission

Detailed Project Description

Welcome to the TodoList API project! In this challenge, you will design and implement a RESTful API for managing a simple to-do list application. This problem introduces fundamental concepts in backend development, including API design, CRUD operations, data persistence, and validation.

By completing this project, you will gain hands-on experience building a structured API with standardized request and response formats, as well as handling validation and edge cases.

Core Functionality

Your task is to implement a REST API that supports the following functionalities:

  1. Creating Tasks: Add new tasks with a title and optional description.
  2. Retrieving Tasks: Fetch tasks individually or as a list.
  3. Updating Tasks: Modify task attributes, such as updating its title, description, or completion status.
  4. Deleting Tasks: Remove tasks permanently from the system.

This problem will challenge you to design a well-structured API while ensuring reliability through validation and error handling.

API Specification

1. Add a Task

  • Endpoint: POST /tasks
  • Request Body:
{ "title": "string", // Required: The title of the task "description": "string" // Optional: A brief description of the task }
  • Response:
{ "id": integer, // Unique identifier for the task "title": "string", "description": "string", "completed": false }
  • Error Responses:

    • 400 Bad Request if the title is missing:
    { "error": "Title is required." }

2. Retrieve All Tasks

  • Endpoint: GET /tasks
  • Response:
{ "tasks": [ { "id": integer, "title": "string", "description": "string", "completed": boolean } ] }
  • Error Responses:
    • 500 Internal Server Error if there is a server-side failure.

3. Retrieve a Task by ID

  • Endpoint: GET /tasks/{id}
  • Response:
{ "id": integer, "title": "string", "description": "string", "completed": boolean }
  • Error Responses:

    • 404 Not Found if the task ID does not exist:
    { "error": "Task not found." }

4. Update a Task

  • Endpoint: PUT /tasks/{id}
  • Request Body:
{ "title": "string", // Optional "description": "string", // Optional "completed": boolean // Optional }
  • Response:
{ "id": integer, "title": "string", "description": "string", "completed": boolean }
  • Error Responses:

    • 400 Bad Request if the request body is invalid:
    { "error": "Invalid request body." }
    • 404 Not Found if the task ID does not exist.

5. Delete a Task

  • Endpoint: DELETE /tasks/{id}
  • Response:
{ "message": "Task deleted successfully." }
  • Error Responses:

    • 404 Not Found if the task does not exist:
    { "error": "Task not found." }

Constraints

  • Title Length: Task titles cannot exceed 255 characters.
  • Description Length: Task descriptions cannot exceed 1,000 characters.
  • Task Count: The total number of tasks in the system will not exceed 10,000.
  • ID Format: Each task is assigned a unique integer ID.

Objectives

  • Develop a RESTful API that meets standardized CRUD requirements.
  • Validate responses and error handling for each operation, ensuring reliability under standard and edge case scenarios.
  • Implement structured testing for real-world scenarios, covering essential validation cases for robust API design.

Outcome

This project provides a foundational introduction to backend API development. By implementing a TodoList API, you will practice designing clean API endpoints, structuring responses, handling edge cases, and ensuring data validation.

Upon completing this challenge, you will have built a robust and efficient API that meets real-world requirements. Good luck!

Project Completion Criteria

  • Create a new task: Verifies task creation, expecting fields like `id`, `title`, `description`, and `completed` in the response.
  • Retrieve a task by ID: Confirms that tasks can be accurately retrieved after creation.
  • Update a task: Tests updating a task’s information and ensures the updated values reflect correctly.
  • Delete a task and confirm deletion: Ensures a task can be deleted and verifies it no longer exists.
  • Create a task with an empty title: Attempts to create a task without a title to ensure that proper validation prevents it, expecting an appropriate error message.