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 /users/{id} endpoint looks up a single user document in the MongoDB local.user collection by its ObjectId. The id path parameter must be a valid 24-character hexadecimal string matching a stored document’s _id. If no document is found for the given ID, the controller raises an HTTP 404 exception with the detail "User Not Found!". GET /users/{id}

Path Parameters

id
string
required
MongoDB ObjectId (24-character hex string) identifying the user document to retrieve. Example: 64a1b2c3d4e5f6789abcdef0.

Response Fields

id
string
The MongoDB ObjectId serialized as a 24-character hexadecimal string.
name
string
The user’s full name.
age
integer
The user’s age.
email
string
The user’s email address.

Example Request

curl http://localhost:5000/users/64a1b2c3d4e5f6789abcdef0

Example Response

A successful request returns HTTP 200 OK with a single user object.
{
  "id": "64a1b2c3d4e5f6789abcdef0",
  "name": "Alice",
  "age": 30,
  "email": "alice@example.com"
}

Error Responses

404 Not Found

Returned when no user document exists for the provided id.
{
  "detail": "User Not Found!"
}
Passing a string that is not a valid 24-character hexadecimal ObjectId (for example, a randomly typed string) will cause a bson.errors.InvalidId exception. Always ensure id is a properly formatted ObjectId.

Build docs developers (and LLMs) love