The Grocery Application is a RESTful API designed to manage grocery items. It provides endpoints for administrators to add, view, update, and delete products, as well as manage inventory levels.
Adds a new product to the system.
- Method: POST
- URL:
/api/v1/admin/products
- Request Body:
{ "name": "Samsung phone", "price": 50000, "quantity": 50 }
Retrieves a list of all available products.
- Method: GET
- URL:
/api/v1/admin/products
Retrieves information about a specific product by ID.
- Method: GET
- URL:
/api/v1/admin/products/{productId}
- Example:
/api/v1/admin/products/5
Updates details (name, price, quantity) of a specific product.
- Method: PUT
- URL:
/api/v1/admin/products/{productId}
- Request Body:
{ "name": "Apple phone", "price": 101000, "quantity": 2 }
- Example:
/api/v1/admin/products/2
Removes a product from the system by ID.
- Method: DELETE
- URL:
/api/v1/admin/products/{productId}
- Example:
/api/v1/admin/products/4
Updates the inventory level of a specific product.
- Method: PUT
- URL:
/api/v1/admin/products/{productId}/inventory
- Request Body: The new quantity to add (integer).
10
- Example:
/api/v1/admin/products/1/inventory
You can make HTTP requests to the provided endpoints using tools like curl or Postman. Here are some example HTTP requests:
POST /api/v1/admin/products HTTP/1.1
Host: localhost:9999
Content-Type: application/json
Content-Length: 75
{
"name": "Samsung phone",
"price": 50000,
"quantity": 50
}
GET /api/v1/admin/products HTTP/1.1
Host: localhost:9999
GET /api/v1/admin/products/5 HTTP/1.1
Host: localhost:9999
PUT /api/v1/admin/products/2 HTTP/1.1
Host: localhost:9999
Content-Type: application/json
Content-Length: 68
{
"name": "Apple phone",
"price": 101000,
"quantity": 2
}
DELETE /api/v1/admin/products/4 HTTP/1.1
Host: localhost:9999
PUT /api/v1/admin/products/1/inventory HTTP/1.1
Host: localhost:9999
Content-Type: application/json
Content-Length: 2
10