GET /api/products
Retrieve a paginated list of products.Authentication
Not required.Query Parameters
Page number for pagination
Number of products per page
Response
Array of product objects
Total number of products
Current page number
Products per page
Total number of pages
Example Request
Example Response
GET /api/products/search
Search products using fuzzy search.Authentication
Not required.Query Parameters
Search query string (searches in name and description fields)
Response
Array of matching product objects
Number of results found
Example Request
Example Response
Error Responses
400 Bad Request- Search query ‘q’ is required500 Internal Server Error- Search failed
The search uses Fuse.js for fuzzy matching with a threshold of 0.4, searching across product names and descriptions.
GET /api/products/:id
Retrieve a single product by ID.Authentication
Not required.Path Parameters
Product ID
Response
Product information
Example Request
Example Response
Error Responses
404 Not Found- Product not found500 Internal Server Error- Failed to fetch product
POST /api/products
Create a new product.Authentication
Required. Include JWT token inAuthorization header.
Request Body
Product name
Product price
Product description
Initial stock quantity
Product category
Response
Created product information
Example Request
Example Response
Error Responses
400 Bad Request- Name and price are required401 Unauthorized- Missing or invalid authentication token500 Internal Server Error- Failed to create product