This documentation outlines the various API routes for both the Lost and Found modules, describing the required inputs and expected responses for each route.
- Uses Amazon S3 for storing images.
- 400 Bad Request: Invalid input or request.
- 403 Forbidden: Unauthorized access.
- 500 Internal Server Error: An error occurred on the server.
- Description: Add a new lost item along with optional images.
- Request:
- Form Data:
form_data
(string): JSON string containing the details of the lost item.images
(list of UploadFile, optional): Images related to the lost item.
- Form Data:
- Response:
200 OK
: Item added successfully.{ "message": "Data inserted successfully" }
500 Internal Server Error
: Error message.{ "detail": "An error occurred: <error_message>" }
- Description: Retrieve a list of all lost item names along with their image URLs, sorted by creation date.
- Response:
200 OK
: List of lost items with associated images.[ { "id": 1, "name": "Laptop", "images": ["https://s3.amazonaws.com/lost-images/1.jpg"] }, { "id": 2, "name": "Backpack", "images": [] } ]
500 Internal Server Error
: Error message.{ "detail": "failed to fetch items" }
- Description: Retrieve details of a specific lost item along with its associated images.
- Request Parameters:
id
(int): The ID of the lost item.
- Response:
200 OK
: Details of the lost item.{ "id": 1, "name": "Laptop", "description": "Black Dell Laptop", "images": ["https://s3.amazonaws.com/lost-images/1.jpg"] }
404 Not Found
: If the item is not found.{ "detail": "Item not found" }
500 Internal Server Error
: Error message.{ "detail": "Failed to fetch items: <error_message>" }
- Description: Delete a lost item by its ID.
- Request:
- Form Data:
item_id
(int): The ID of the item to be deleted.
- Form Data:
- Response:
200 OK
: Item deleted successfully.{ "message": "Item deleted successfully!" }
500 Internal Server Error
: Error message.{ "detail": "Failed to delete item: <error_message>" }
- Description: Edit an existing lost item.
- Request:
- Form Data:
item_id
(int): The ID of the item to be updated.form_data
(string): JSON string with updated details of the item.
- Form Data:
- Response:
200 OK
: Item updated successfully.{ "message": "Item updated" }
500 Internal Server Error
: Error message.{ "detail": "Error: <error_message>" }
- Description: Search for lost items by a query.
- Request Parameters:
query
(string): The search query.max_results
(int, optional, default=100): The maximum number of results to return.
- Response:
200 OK
: List of lost items that match the search query.[ { "id": 1, "name": "Laptop", "images": ["https://s3.amazonaws.com/lost-images/1.jpg"] }, { "id": 2, "name": "Backpack", "images": [] } ]
500 Internal Server Error
: Error message.{ "detail": "Error: <error_message>" }
- Description: Add a new found item along with optional images.
- Request:
- Form Data:
form_data
(string): JSON string containing the details of the found item.images
(list of UploadFile, optional): Images related to the found item.
- Form Data:
- Response:
200 OK
: Item added successfully.{ "message": "Data inserted successfully" }
500 Internal Server Error
: Error message.{ "detail": "An error occurred: <error_message>" }
- Description: Retrieve a list of all found item names along with their image URLs.
- Response:
200 OK
: List of found items with associated images.[ { "id": 1, "name": "Laptop", "images": ["https://s3.amazonaws.com/found-images/1.jpg"] }, { "id": 2, "name": "Backpack", "images": [] } ]
500 Internal Server Error
: Error message.{ "detail": "failed to fetch items" }
- Description: Retrieve details of a specific found item along with its associated images.
- Request Parameters:
id
(int): The ID of the found item.
- Response:
200 OK
: Details of the found item.{ "id": 1, "name": "Laptop", "description": "Black Dell Laptop", "images": ["https://s3.amazonaws.com/found-images/1.jpg"] }
404 Not Found
: If the item is not found.{ "detail": "Item not found" }
500 Internal Server Error
: Error message.{ "detail": "Failed to fetch items: <error_message>" }
- Description: Delete a found item by its ID.
- Request:
- Form Data:
item_id
(int): The ID of the item to be deleted.
- Form Data:
- Response:
200 OK
: Item deleted successfully.{ "message": "Item deleted successfully!" }
500 Internal Server Error
: Error message.{ "detail": "Failed to delete item: <error_message>" }
- Description: Edit an existing found item.
- Request:
- Form Data:
item_id
(int): The ID of the item to be updated.form_data
(string): JSON string with updated details of the item.
- Form Data:
- Response:
200 OK
: Item updated successfully.{ "message": "Item updated" }
500 Internal Server Error
: Error message.{ "detail": "Error: <error_message>" }
- Description: Search for found items by a query.
- Request Parameters:
query
(string): The search query.max_results
(int, optional, default=100): The maximum number of results to return.
- Response:
200 OK
: List of found items that match the search query.[ { "id": 1, "name": "Laptop", "images": ["https://s3.amazonaws.com/found-images/1.jpg"] }, { "id": 2, "name": "Backpack", "images": [] } ]
500 Internal Server Error
: Error message.{ "detail": "Error: <error_message>" }