Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/tutosrive/fastapi-CRUD-MongoDB/llms.txt

Use this file to discover all available pages before exploring further.

The GET /tasks/ endpoint retrieves every task document stored in MongoDB and returns them as a JSON array. No filtering, pagination, or authentication parameters are required. If no tasks exist in the collection yet, the endpoint returns an empty array ([]) rather than an error — making it safe to call at any time without defensive handling on the client. GET /tasks/

Response Fields

id
string
MongoDB ObjectId serialised as a 24-character hex string. Generated automatically by MongoDB on insert.
title
string
The short title of the task.
description
string
A detailed description of what the task involves.
completed
boolean
Whether the task has been completed. Defaults to false when a task is first created.
created_by
string
Identifier for the user who created the task (e.g. an email address or username).

Example Request

curl http://localhost:5000/tasks/

Example Response

[
  {
    "id": "64a1b2c3d4e5f6789abcde01",
    "title": "Buy groceries",
    "description": "Milk, eggs, bread",
    "completed": false,
    "created_by": "alice@example.com"
  },
  {
    "id": "64a1b2c3d4e5f6789abcde02",
    "title": "Write unit tests",
    "description": "Cover all controller methods with pytest",
    "completed": true,
    "created_by": "bob@example.com"
  }
]
When the task collection is empty, the response is [] with an HTTP 200 status — not a 404. No special error handling is needed for the empty-list case.

Error Responses

StatusDetailCause
500 Internal Server ErrorServer error messageDatabase connection failure or unexpected exception.

Build docs developers (and LLMs) love