Register a new user.
{
"name": "John Doe",
"email": "john@example.com",
"password": "password123",
}
Status: 201 Created
Body:{ "message": "User is Registered" }
Login with existing user credentials.
{
"email": "john@example.com",
"password": "password123"
}
Status: 201 Created
{
"token": "your_jwt_token",
"message": "Login Successfull"
}
{
"name": "mobile"
}
Status: 201 Created
{
"message": "Category added successfully"
}
Get all categories.
Status: 200 OK Body:
[
{
"_id": "category_id",
"name": "mobile"
},
{
"_id": "category_id",
"name": "laptop"
},
...
]
Create a new product.
Request Body:
{
"title": "oppo",
"description": "camera phone",
"price": 9500,
"availability": true,
"categoryId": "category_id"
}
Response:
Status: 201 Created Body:
{
"message": "Product added successfully"
}
Get all products under a specific category.
Response:
Status: 200 OK Body:
[
{
"_id": "product_id",
"title": "oppo",
"description": "camera phone",
"price": 9500,
"availability": true,
"categoryId": "category_id"
},
{
"_id": "product_id",
"title": "redmi",
"description": "durable phone",
"price":10500,
"availability": false,
"categoryId": "category_id"
},
...
]
Get a specific product by its ID.
Response:
Status: 200 OK Body:
{
"_id": "product_id",
"title": "oppo",
"description": "camera phone",
"price": 9500,
"availability": true,
"categoryId": "category_id"
}
Get all data from the user's cart.
Response:
Status: 200 OK Body:
{
"_id": "cart_id",
"userId": "user_id",
"items": [
{
"_id": "item_id",
"productId": "product_id",
"quantity": 2,
"price": 9500
},
...
]
}
Add a product to the cart.
Response:
Status: 200 OK Body:
{ "message": "Product added to cart successfully" }
Update the quantity of a product in the cart.
Request Body:
{
"quantity": 3
}
Response:
Status: 200 OK Body:
{
"message": "Cart item is updated now"
}
Delete an item from the cart.
Response:
Status: 200 OK Body:
{
"message": "cart item is deleted now"
}
Place an order for a specific product.
Response:
Status: 201 OK Body:
{
"message": "order is placed now"
}
Get the order history for the authenticated user.
Response:
Status: 200 OK Body:
[
{
"_id": "order_id",
"userId": "user_id",
"items": [
{
"_id": "item_id",
"productId": "product_id",
"quantity": 2
},
...
],
"totalPrice": 19000,
"date": "2023-07-26T10:15:00.000Z"
},
...
]
Get detailed information of a specific order by its ID.
Response:
Status: 200 OK Body:
{
"_id": "order_id",
"userId": "user_id",
"items": [
{
"_id": "item_id",
"productId": "product_id",
"quantity": 2
},
...
],
"totalPrice":19000,
"date": "2023-07-26T10:15:00.000Z"
}