http://localhost:4000/api
Most endpoints require JWT authentication. Add the token to your requests:
Authorization: Bearer <your_jwt_token>
GET /productsQuery Parameters:
category(optional): Filter by categorybrand(optional): Filter by brandprice(optional): Filter by maximum price
Example:
GET /products?category=Phone&brand=Apple&price=1000GET /products/:slugExample:
GET /products/iphone-14POST /products
Authorization: Bearer <token>
Content-Type: multipart/form-dataBody:
name(required): stringdescription(required): stringprice(required): numbercategory(required): enum ['Phone', 'Computers', 'Smartwatch', 'Camera', 'Headphones', 'Gaming', 'Other']brand(required): stringstock(required): numberimages(required): file(s) (up to 10 images)
PATCH /products/:id
Authorization: Bearer <token>
Content-Type: multipart/form-dataBody: Any product fields you want to update, including new images.
Example:
{
"price": 899,
"stock": 45,
"images": [file1, file2]
}DELETE /products/:id
Authorization: Bearer <token>POST /products/:id/reviews
Authorization: Bearer <token>
Content-Type: application/jsonBody:
{
"comment": "Great product!",
"rating": 5
}GET /products/:id/reviewsPOST /user/signup
Content-Type: application/jsonBody:
{
"email": "user@example.com",
"password": "StrongPass123!",
"name": "John Doe",
"role": "user"
}POST /user/login
Content-Type: application/jsonBody:
{
"email": "user@example.com",
"password": "StrongPass123!"
}GET /user
Authorization: Bearer <token>GET /user/search?query=<search_term>
Authorization: Bearer <token>Example:
GET /user/search?query=adminDELETE /user/:id
Authorization: Bearer <token>POST /user/forgot-password
Content-Type: application/jsonBody:
{
"email": "user@example.com"
}POST /user/reset-password
Content-Type: application/jsonBody:
{
"token": "reset_token_received_via_email",
"newPassword": "NewStrongPass123!"
}PATCH /user/profile
Authorization: Bearer <token>
Content-Type: multipart/form-dataBody:
name(optional): stringimage(optional): file (profile image)
Example:
PATCH /user/profile
Authorization: Bearer <token>
Content-Type: multipart/form-dataForm-data:
name: "Jane Doe"image: (upload a file)
-
Create a Postman Collection
- Open Postman
- Create a new collection called "E-commerce API"
- Create folders for "Products" and "Users"
-
Set up Environment Variables
- Create a new environment
- Add variables:
BASE_URL: http://localhost:4000/apiTOKEN: (leave empty initially)
-
Authentication Flow
- Create a user using the signup endpoint
- Login with the created user
- Copy the token from the response
- Set the token in your environment variable
-
Testing Protected Routes
- Make sure to include the Authorization header:
Authorization: Bearer {{TOKEN}} -
Testing File Uploads
- Use form-data in Postman
- Set the key type to "File" for image uploads
Example Postman Test Sequence:
- Create user (POST /user/signup)
- Login (POST /user/login)
- Update profile (PATCH /user/profile)
- Create product (POST /products)
- Get all products (GET /products)
- Add review (POST /products/:id/reviews)
- Get product reviews (GET /products/:id/reviews)