This is an API for managing an E-commerce website's backend operations, including user authentication, product management, cart, and order processing
Backend Deploy-: https://triveous-ecommerce-api-l6ek.onrender.com/
- User registration and login with JWT authentication.
- Product management: Add, retrieve, and search products by category.
- Cart management: Add, remove, and update product quantities in the cart.
- Order processing: Place orders and retrieve order history.
- Node.js: A JavaScript runtime for server-side development.
- Express.js: A web application framework for Node.js.
- MongoDB: A NoSQL database for storing data.
- JWT: JSON Web Tokens for authentication.
- Swagger: API documentation tool.
- Other Dependencies: Various Node.js libraries and modules.
Before getting started, make sure you have the following installed:
- Node.js: Download Node.js
- MongoDB: Download MongoDB
-
Clone the repository:
git clone https://github.com/himanshu60/Ecommerce-Api.git
-
Navigate to the project directory:
cd Ecommerce-Api npm init -y
-
Install dependencies:
npm install express mongoose bcrypt jsonwebtoken swagger-jsdoc swagger-ui-express
-
Application Start
node index.js
To use protected routes, you must authenticate by obtaining a JWT token. Use the /users/login route to log in and get the token.
User Registration: POST /users/register
User Login: POST /users/login
Add a Product: POST /products/add-prod
Get Product Categories: GET /products/prod-category
Get Products: GET /products/products
Get Product by ID: GET /products/products/{id}
Add to Cart: POST /cart/addtocart/{productId}
Remove from Cart: DELETE /cart/prod-removetocart/{productId}
Get Cart Contents: GET /cart/cart
Increase Product Quantity in Cart: POST /cart/qty-increase/{productId}
Decrease Product Quantity in Cart: POST /cart/qty-decrease/{productId}
Place an Order: POST /orders/order-place
Get Order Details: GET /orders/order-details
Get Order by ID: GET /orders/order/{orderId}
For detailed API documentation, visit the Swagger Documentation.