StockEase API (1.0.0)

Download OpenAPI specification:

Team StockEase: support@stockease.com License: MIT

StockEase API provides comprehensive inventory management capabilities including product CRUD operations, JWT-based authentication, pagination, search, and stock analytics. All endpoints except login and health check require valid JWT authentication with USER or ADMIN roles.

Authentication

User authentication and JWT token management

Authenticate user and generate JWT token

Validates user credentials against stored user records via Spring Security. Upon successful authentication, issues a signed JWT token with embedded user role. Token can be used for subsequent API requests requiring USER or ADMIN role authorization.

Authorizations:
BearerAuth
Request Body schema: application/json
required
username
required
string non-empty

User account name (must not be blank)

password
required
string non-empty

User account password (must not be blank)

Responses

Request samples

Content type
application/json
{
  • "username": "admin",
  • "password": "password123"
}

Response samples

Content type
application/json
{
  • "success": true,
  • "message": "Login successful",
  • "data": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhZG1pbiIsInJvbGUiOiJBRE1JTiIsImlhdCI6MTcwMDAwMDAwMH0.signature"
}

Products

Product inventory management, CRUD operations, pagination, and analytics

Retrieve all products

Loads entire inventory without pagination. Returns all products sorted by ID. Use /api/products/paged for large datasets to prevent memory issues.

Authorizations:
BearerAuth

Responses

Response samples

Content type
application/json
[
  • {
    },
  • {
    }
]

Create a new product (ADMIN only)

Creates a new product with provided name, quantity, and price. Validates all required fields and business rules:

  • Name must be non-empty
  • Quantity cannot be negative
  • Price must be positive (> 0) Automatically calculates totalValue = quantity * price
Authorizations:
BearerAuth
Request Body schema: application/json
required
name
required
string
quantity
required
integer >= 0
price
required
number <double> >= 0.01

Responses

Request samples

Content type
application/json
{
  • "name": "New Laptop",
  • "quantity": 25,
  • "price": 1299.99
}

Response samples

Content type
application/json
{
  • "id": 3,
  • "name": "New Laptop",
  • "quantity": 25,
  • "price": 1299.99,
  • "totalValue": 32499.75
}

Retrieve a single product by ID

Returns product details if found, otherwise 404 error.

Authorizations:
BearerAuth
path Parameters
id
required
integer <int64>
Example: 1

Product identifier

Responses

Response samples

Content type
application/json
{
  • "success": true,
  • "message": "Product fetched successfully",
  • "data": {
    }
}

Delete a product (ADMIN only)

Deletes a product by ID. Returns 404 if product not found. Deletion checks product existence first to avoid orphaned references.

Authorizations:
BearerAuth
path Parameters
id
required
integer <int64>
Example: 1

Product identifier

Responses

Response samples

Content type
application/json
{
  • "success": true,
  • "message": "Product with ID 1 has been successfully deleted.",
  • "data": null
}

Retrieve products with pagination

Returns paginated product list with metadata. Prevents loading entire table into memory. Default page size is 10 items. Includes total count and page information for client-side pagination controls.

Authorizations:
BearerAuth
query Parameters
page
integer >= 0
Default: 0
Example: page=0

Zero-based page number (default 0)

size
integer >= 1
Default: 10
Example: size=10

Items per page (default 10, must be positive)

Responses

Response samples

Content type
application/json
{
  • "success": true,
  • "message": "Paged products fetched successfully",
  • "data": {
    }
}

Get products with critically low stock

Returns products where quantity is below reorder threshold (5 items). If all products adequately stocked, returns success message with empty list.

Authorizations:
BearerAuth

Responses

Response samples

Content type
application/json
Example
[ ]

Search products by name

Case-insensitive substring search. For example, searching "apple" returns products like "Apple Juice", "APPLE", "Green Apple", etc. Returns 204 NO_CONTENT if no matches found.

Authorizations:
BearerAuth
query Parameters
name
required
string
Example: name=laptop

Search term (substring, case-insensitive)

Responses

Response samples

Content type
application/json
[
  • {
    }
]

Update product quantity

Updates quantity for a specific product. Automatically recalculates total stock value. Prevents negative quantities.

Authorizations:
BearerAuth
path Parameters
id
required
integer <int64>
Example: 1

Product identifier

Request Body schema: application/json
required
quantity
required
integer >= 0

New quantity (cannot be negative)

Responses

Request samples

Content type
application/json
{
  • "quantity": 75
}

Response samples

Content type
application/json
{
  • "success": true,
  • "message": "Quantity updated successfully",
  • "data": {
    }
}

Update product price

Updates price for a specific product. Automatically recalculates total stock value. Prevents zero or negative prices.

Authorizations:
BearerAuth
path Parameters
id
required
integer <int64>
Example: 1

Product identifier

Request Body schema: application/json
required
price
required
number <double> >= 0.01

New price (must be positive)

Responses

Request samples

Content type
application/json
{
  • "price": 1199.99
}

Response samples

Content type
application/json
{
  • "success": true,
  • "message": "Price updated successfully",
  • "data": {
    }
}

Update product name

Updates name for a specific product. Name must be non-empty. Uniqueness constraint enforced at database level.

Authorizations:
BearerAuth
path Parameters
id
required
integer <int64>
Example: 1

Product identifier

Request Body schema: application/json
required
name
required
string non-empty

New product name (must not be empty)

Responses

Request samples

Content type
application/json
{
  • "name": "High-Performance Laptop"
}

Response samples

Content type
application/json
{
  • "success": true,
  • "message": "Name updated successfully",
  • "data": {
    }
}

Calculate total inventory value

Computes sum of (quantity * price) for all products. Useful for financial reporting and inventory valuation. Database-optimized aggregation query.

Authorizations:
BearerAuth

Responses

Response samples

Content type
application/json
{
  • "success": true,
  • "message": "Total stock value fetched successfully",
  • "data": 99999.99
}

Health

Application health check and database connectivity monitoring

Health check endpoint

Simple health check for orchestration and monitoring systems (Kubernetes, Docker, load balancers). Validates database connectivity via lightweight JDBC connection test. Returns 200 OK if database reachable; 500 error if unreachable. No authentication required. Used by:

  • Kubernetes (liveness/readiness probes)
  • Docker (healthcheck instruction)
  • Load balancers (backend health verification)
  • Monitoring systems (Prometheus, DataDog, etc.)
Authorizations:
BearerAuth

Responses