Complete reference for the Grocery Management System REST API
The Grocery Management System provides a RESTful API for programmatic access to all system functionality. All API endpoints require authentication except for the login and registration endpoints.
https://grocerymanage.netlify.app/
Most endpoints require a JWT token for authentication. Include the token in the Authorization header:
Authorization: Bearer YOUR_JWT_TOKEN
/register
Create a new user account with username and password.
{
"username": "newuser",
"password": "securepassword123"
}
{
"user_id": 42,
"message": "User registered successfully"
}
{
"error": "Username and password are required"
} (Status: 400)
/login
Authenticate and receive a JWT token valid for 2 hours.
{
"username": "existinguser",
"password": "securepassword123"
}
{
"message": "Login successful",
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"user_id": 42
}
{
"error": "Username and password are required"
} (Status: 400)
{
"error": "Invalid username or password"
} (Status: 401)
Authorization
header for protected routes:
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
/getProducts
Retrieve a list of all products in the inventory.
Authorization: Bearer YOUR_JWT_TOKEN
[
{
"name": "rice",
"price_per_unit": 40,
"product_id": 1,
"uom_id": 2,
"uom_name": "kg"
},
{
"name": "toothpaste",
"price_per_unit": 30,
"product_id": 2,
"uom_id": 1,
"uom_name": "each"
},
{
"name": "Wheat",
"price_per_unit": 40,
"product_id": 3,
"uom_id": 2,
"uom_name": "kg"
}
]
/insertProduct
Add a new product to the inventory.
Authorization: Bearer YOUR_JWT_TOKEN
Content-Type: multipart/form-data
data={
"product_name": "Bananas",
"unit": "kg",
"price_per_unit": 35
}
{
"product_id": 42
}
/deleteProduct
Remove a product from the inventory.
Authorization: Bearer YOUR_JWT_TOKEN
Content-Type: multipart/form-data
{
"product_id": "42"
}
{
"product_id": 42
}
/getAllOrders
Retrieve a list of all orders with their details.
Authorization: Bearer YOUR_JWT_TOKEN
[
"customer_name": "Sneha",
{
"datetime": "Wed, 02 Apr 2025 00:00:00 GMT",
"order_details": [
{
"order_id": 1,
"price_per_unit": 40,
"product_name": "rice",
"quantity": 2,
"total_price": 80
}
],
"order_id": 1,
"total": 300
},
{
"customer_name": "Tanya",
"datetime": "Wed, 02 Apr 2025 11:12:17 GMT",
"order_details": [
{
"order_id": 2,
"price_per_unit": 30,
"product_name": "toothpaste",
"quantity": 1,
"total_price": 30
}
],
"order_id": 2,
"total": 30
},
{
"customer_name": "Aditya",
"datetime": "Wed, 02 Apr 2025 07:51:37 GMT",
"order_details": [
{
"order_id": 3,
"price_per_unit": 40,
"product_name": "Wheat",
"quantity": 1,
"total_price": 40
}
],
"order_id": 3,
"total": 40
}
]
/insertOrder
Create a new order with multiple products.
Authorization: Bearer YOUR_JWT_TOKEN
Content-Type: multipart/form-data
{
"product": "Wheat"
"price": 40,
"quantity": 1,
"total-cost": 230.00 Rs
}
{
"order_id": 102
}
/getUOM
Retrieve a list of all available units of measure.
Authorization: Bearer YOUR_JWT_TOKEN
[
{
"uom_id": 1,
"uom_name": "each"
},
{
"uom_id": 2,
"uom_name": "kg"
}
]