Welcome to the API documentation for our application. This document provides detailed information about the available endpoints for managing Items and Users. The API is built using Express.js and Firebase Firestore.
All endpoints are prefixed with the base URL of your server. For example:
https://your-domain.com/api
Replace https://your-domain.com/api with your actual server URL.
Note: The current endpoints do not implement authentication. For secure applications, consider adding authentication mechanisms like JWT or OAuth.
Retrieve a list of all items.
- URL:
/items - Method:
GET - URL Parameters: None
- Body Parameters: None
Success Response:
- Code:
200 OK - Content:
[ { "id": "item1", "name": "Item One", "description": "Description of Item One" }, { "id": "item2", "name": "Item Two", "description": "Description of Item Two" } ]
Error Response:
- Code:
500 Internal Server Error - Content:
{ "error": "Error message" }
Retrieve a single item by its ID.
- URL:
/items/:id - Method:
GET - URL Parameters:
id(string): The ID of the item to retrieve.
- Body Parameters: None
Success Response:
- Code:
200 OK - Content:
{ "id": "item1", "name": "Item One", "description": "Description of Item One" }
Error Response:
- Code:
404 Not Found - Content:
{ "error": "No Item Found" }
Add a new item to the database.
- URL:
/items - Method:
POST - URL Parameters: None
- Body Parameters:
name(string): Name of the item.description(string): Description of the item.
Request Body Example:
{
"name": "Item One",
"description": "Description of Item One"
}Success Response:
- Code:
200 OK - Content:
{ "name": "Item One", "description": "Description of Item One" }
Error Response:
- Code:
500 Internal Server Error - Content:
{ "error": "Invalid Item Schema" }
Retrieve a single user by their ID.
- URL:
/users/:id - Method:
GET - URL Parameters:
id(string): The ID of the user to retrieve.
- Body Parameters: None
Success Response:
- Code:
200 OK - Content:
{ "id": "user1", "username": "UserOne", "email": "userone@example.com" }
Error Response:
- Code:
404 Not Found - Content:
{ "error": "No User Found" }
Retrieve all items associated with a specific user.
- URL:
/users/:id/items - Method:
GET - URL Parameters:
id(string): The ID of the user whose items are to be retrieved.
- Body Parameters: None
Success Response:
- Code:
200 OK - Content:
[ "item1", "item2" ]
Error Response:
- Code:
404 Not Found - Content:
{ "error": "No User Found" }
Add a new user to the database.
- URL:
/users - Method:
POST - URL Parameters: None
- Body Parameters:
username(string): Username of the user.email(string): Email address of the user.
Request Body Example:
{
"username": "UserOne",
"email": "userone@example.com"
}Success Response:
- Code:
200 OK - Content:
{ "username": "UserOne", "email": "userone@example.com", "items": [] }
Error Response:
- Code:
500 Internal Server Error - Content:
{ "error": "Invalid User Schema" }
All error responses follow a consistent format:
{
"error": "Error message"
}- 500 Internal Server Error: Indicates a server-side issue, such as an invalid schema or database error.
- 404 Not Found: Indicates that the requested resource (Item or User) does not exist.
Represents an item in the database.
| Field | Type | Description |
|---|---|---|
id |
string | Unique identifier for the item. |
name |
string | Name of the item. |
description |
string | Description of the item. |
export interface Item {
id: string;
name: string;
description: string;
}Represents a user in the database.
| Field | Type | Description |
|---|---|---|
id |
string | Unique identifier for the user. |
username |
string | Username of the user. |
email |
string | Email address of the user. |
items |
string[] | Array of item IDs associated with the user. |
export interface User {
id: string;
username: string;
email: string;
items: string[];
}Request:
GET /items HTTP/1.1
Host: your-domain.comResponse:
[
{
"id": "item1",
"name": "Item One",
"description": "Description of Item One"
},
{
"id": "item2",
"name": "Item Two",
"description": "Description of Item Two"
}
]Request:
GET /items/item1 HTTP/1.1
Host: your-domain.comResponse:
{
"id": "item1",
"name": "Item One",
"description": "Description of Item One"
}Error Response:
{
"error": "No Item Found"
}Request:
POST /items HTTP/1.1
Host: your-domain.com
Content-Type: application/json
{
"name": "Item Three",
"description": "Description of Item Three"
}Response:
{
"name": "Item Three",
"description": "Description of Item Three"
}Error Response:
{
"error": "Invalid Item Schema"
}Request:
GET /users/user1 HTTP/1.1
Host: your-domain.comResponse:
{
"id": "user1",
"username": "UserOne",
"email": "userone@example.com"
}Error Response:
{
"error": "No User Found"
}Request:
GET /users/user1/items HTTP/1.1
Host: your-domain.comResponse:
[
"item1",
"item2"
]Error Response:
{
"error": "No User Found"
}Request:
POST /users HTTP/1.1
Host: your-domain.com
Content-Type: application/json
{
"username": "UserTwo",
"email": "usertwo@example.com"
}Response:
{
"username": "UserTwo",
"email": "usertwo@example.com",
"items": []
}Error Response:
{
"error": "Invalid User Schema"
}