SCATCH is an e-commerce platform where users can buy bags. This documentation provides details about the backend API, built using the MERN stack, following RESTful principles.
http://yourdomain.com/api
All protected routes require a JWT token for authentication. Include the token in the Authorization header as:
Authorization: Bearer <token>
Endpoint: POST /auth/register
- Request Body:
{ "name": "John Doe", "email": "john@example.com", "password": "password123" } - Response:
{ "message": "User registered successfully", "token": "<jwt_token>" }
Endpoint: POST /auth/login
- Request Body:
{ "email": "john@example.com", "password": "password123" } - Response:
{ "message": "Login successful", "token": "<jwt_token>" }
Endpoint: GET /products
- Response:
[ { "_id": "12345", "name": "Leather Backpack", "price": 59.99, "description": "Premium leather backpack", "category": "Backpacks", "stock": 10 } ]
Endpoint: GET /products/:id
- Response:
{ "_id": "12345", "name": "Leather Backpack", "price": 59.99, "description": "Premium leather backpack", "category": "Backpacks", "stock": 10 }
Endpoint: POST /products
- Request Body:
{ "name": "Leather Backpack", "price": 59.99, "description": "Premium leather backpack", "category": "Backpacks", "stock": 10 } - Response:
{ "message": "Product added successfully" }
Endpoint: POST /cart
- Request Body:
{ "productId": "12345", "quantity": 2 } - Response:
{ "message": "Item added to cart" }
Endpoint: GET /cart
- Response:
{ "items": [ { "productId": "12345", "name": "Leather Backpack", "quantity": 2, "price": 59.99 } ], "totalPrice": 119.98 }
Endpoint: POST /orders
- Request Body:
{ "cartId": "67890" } - Response:
{ "message": "Order placed successfully", "orderId": "54321" }
Endpoint: GET /orders
- Response:
[ { "_id": "54321", "status": "Processing", "items": [ { "productId": "12345", "name": "Leather Backpack", "quantity": 2 } ], "totalPrice": 119.98 } ]
Responses follow this structure for errors:
{
"error": "Description of the error"
}This documentation covers the primary API endpoints for the SCATCH backend. Future updates may include payment integration and improved security measures.
Developed by Abhinav Mishra