Product Stock by Warehouse
Query the amount of available stock per product in a specific warehouse. This endpoint is essential for verifying availability before creating orders.
/v1/client/products/stockThis endpoint allows you to obtain the amount of available stock per product in the selected warehouse. It is necessary to provide the Authorization header with the Bearer token obtained previously and also provide a query param with the ID of the warehouse you want to query.
Headers
| Parameter | Type | Required | Description |
|---|---|---|---|
Authorization | string | β Yes | Bearer token obtained from /token/generate endpoint |
Query Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
warehouse_id | integer | β Yes | ID of the warehouse to query |
Examples
- cURL
- JavaScript
- Python
curl -X GET "https://apisandbox.eonwms.com/v1/client/products/stock?warehouse_id=1" \
-H "Authorization: Bearer YOUR_TOKEN"
const warehouseId = 1;
const response = await fetch(
`https://apisandbox.eonwms.com/v1/client/products/stock?warehouse_id=${warehouseId}`,
{
method: 'GET',
headers: {
'Authorization': 'Bearer YOUR_TOKEN'
}
}
);
const stockData = await response.json();
// Display stock information
stockData.data.forEach(product => {
const { sku, description, stock } = product.attributes;
console.log(`SKU: ${sku}`);
console.log(`Product: ${description}`);
console.log(`Available stock: ${stock.quantity}`);
console.log('---');
});
// Check availability for a specific SKU
function checkAvailability(sku, requiredQuantity) {
const product = stockData.data.find(
p => p.attributes.sku === sku
);
if (!product) {
return { available: false, message: 'Product not found' };
}
const availableStock = product.attributes.stock.quantity;
if (availableStock >= requiredQuantity) {
return { available: true, availableStock };
} else {
return {
available: false,
availableStock,
message: `Insufficient stock. Available: ${availableStock}`
};
}
}
import requests
warehouse_id = 1
response = requests.get(
f'https://apisandbox.eonwms.com/v1/client/products/stock?warehouse_id={warehouse_id}',
headers={
'Authorization': 'Bearer YOUR_TOKEN'
}
)
stock_data = response.json()
# Display stock information
for product in stock_data['data']:
attrs = product['attributes']
print(f"SKU: {attrs['sku']}")
print(f"Product: {attrs['description']}")
print(f"Available stock: {attrs['stock']['quantity']}")
print("---")
# Check availability for multiple products
def check_order(order_items):
"""
order_items: list of dictionaries with 'sku' and 'quantity'
"""
results = []
for item in order_items:
product = next(
(p for p in stock_data['data']
if p['attributes']['sku'] == item['sku']),
None
)
if not product:
results.append({
'sku': item['sku'],
'available': False,
'message': 'Product not found'
})
continue
available_stock = product['attributes']['stock']['quantity']
required_quantity = item['quantity']
if available_stock >= required_quantity:
results.append({
'sku': item['sku'],
'available': True,
'available_stock': available_stock
})
else:
results.append({
'sku': item['sku'],
'available': False,
'available_stock': available_stock,
'missing': required_quantity - available_stock
})
return results
# Usage example
order = [
{'sku': 'THISISSKU01', 'quantity': 5},
{'sku': 'THISISSKU2', 'quantity': 10}
]
availability = check_order(order)
for item in availability:
print(f"SKU {item['sku']}: {'Available' if item['available'] else 'Not available'}")
Responses
200Success - List of products with stock
{
"data": [
{
"id": "1",
"type": "product",
"attributes": {
"sku": "THISISSKU01",
"description": "WINGSPAN BOARDGAME",
"stock": {
"quantity": 997
}
}
},
{
"id": "2",
"type": "product",
"attributes": {
"sku": "THISISSKU2",
"description": "WINGSPAN OCEANIA EXPANTION",
"stock": {
"quantity": 500
}
}
}
]
}
401Unauthorized - Invalid token
{
"code": 401,
"fault": {
"arguments": {
"Authorization": "invalid"
},
"type": "InvalidAuthorizationException",
"message": "The request is unauthorized, the access token is invalid."
}
}
422Unprocessable - Invalid warehouse
{
"code": 422,
"fault": {
"arguments": {
"warehouse": "invalid"
},
"type": "warehouseParamIsInvalid",
"message": "the client does not have access to the selected warehouse."
}
}
Response Structureβ
Each product in the data array includes:
Product Informationβ
- id: Internal product ID
- type: Will always be "product"
- attributes: Contains product details
- sku: Unique product code (Stock Keeping Unit)
- description: Product description
- stock: Inventory information
- quantity: Available quantity in the warehouse
Stock Considerationsβ
Real-Time Stockβ
The displayed stock is real-time and considers:
- β Available physical inventory
- β Reservations from orders in process
- β Recent inventory adjustments
Stock DOES NOT Includeβ
- β Products in transit to the warehouse
- β Damaged or quarantined products
- β Scheduled future reservations
Common Use Casesβ
1. Pre-Order Verificationβ
async function validateOrderAvailability(warehouseId, products) {
// Get current stock
const response = await fetch(
`https://apisandbox.eonwms.com/v1/client/products/stock?warehouse_id=${warehouseId}`,
{
headers: { 'Authorization': 'Bearer YOUR_TOKEN' }
}
);
const stockData = await response.json();
const issues = [];
// Check each order product
for (const item of products) {
const productInStock = stockData.data.find(
p => p.attributes.sku === item.sku
);
if (!productInStock) {
issues.push({
sku: item.sku,
type: 'NOT_EXISTS',
message: `Product ${item.sku} does not exist in the warehouse`
});
continue;
}
const available = productInStock.attributes.stock.quantity;
if (available < item.quantity) {
issues.push({
sku: item.sku,
type: 'INSUFFICIENT_STOCK',
message: `Only ${available} units available, ${item.quantity} required`,
available,
required: item.quantity,
missing: item.quantity - available
});
}
}
return {
validOrder: issues.length === 0,
issues
};
}
2. Low Stock Monitorβ
async function monitorLowStock(warehouseId, minimumThreshold = 10) {
const response = await fetch(
`https://apisandbox.eonwms.com/v1/client/products/stock?warehouse_id=${warehouseId}`,
{
headers: { 'Authorization': 'Bearer YOUR_TOKEN' }
}
);
const stockData = await response.json();
const lowStockProducts = stockData.data
.filter(p => p.attributes.stock.quantity <= minimumThreshold)
.map(p => ({
sku: p.attributes.sku,
description: p.attributes.description,
currentStock: p.attributes.stock.quantity,
status: p.attributes.stock.quantity === 0 ? 'OUT_OF_STOCK' : 'LOW_STOCK'
}));
if (lowStockProducts.length > 0) {
console.log(`β οΈ Alert: ${lowStockProducts.length} products with low stock`);
lowStockProducts.forEach(p => {
console.log(`- ${p.sku}: ${p.currentStock} units (${p.status})`);
});
}
return lowStockProducts;
}
3. Inventory Reportβ
async function generateInventoryReport(warehouseId) {
const response = await fetch(
`https://apisandbox.eonwms.com/v1/client/products/stock?warehouse_id=${warehouseId}`,
{
headers: { 'Authorization': 'Bearer YOUR_TOKEN' }
}
);
const stockData = await response.json();
// Calculate metrics
const totalSKUs = stockData.data.length;
const totalUnits = stockData.data.reduce(
(sum, p) => sum + p.attributes.stock.quantity, 0
);
const outOfStockSKUs = stockData.data.filter(
p => p.attributes.stock.quantity === 0
).length;
const inStockSKUs = totalSKUs - outOfStockSKUs;
// Generate report
const report = {
warehouse: warehouseId,
date: new Date().toISOString(),
summary: {
totalSKUs,
inStockSKUs,
outOfStockSKUs,
totalUnits,
availabilityPercentage: ((inStockSKUs / totalSKUs) * 100).toFixed(2) + '%'
},
productDetails: stockData.data.map(p => ({
sku: p.attributes.sku,
description: p.attributes.description,
stock: p.attributes.stock.quantity,
status: p.attributes.stock.quantity === 0 ? 'Out of Stock' :
p.attributes.stock.quantity < 10 ? 'Low Stock' : 'Available'
}))
};
return report;
}
4. External System Synchronizationβ
class InventorySynchronizer {
constructor(token, warehouseId) {
this.token = token;
this.warehouseId = warehouseId;
}
async getChronosStock() {
const response = await fetch(
`https://apisandbox.eonwms.com/v1/client/products/stock?warehouse_id=${this.warehouseId}`,
{
headers: { 'Authorization': `Bearer ${this.token}` }
}
);
return await response.json();
}
async syncWithLocalSystem(updateCallback) {
try {
const chronosStock = await this.getChronosStock();
for (const product of chronosStock.data) {
const { sku, stock } = product.attributes;
// Update local system
await updateCallback(sku, stock.quantity);
}
return {
success: true,
productsSynced: chronosStock.data.length
};
} catch (error) {
return {
success: false,
error: error.message
};
}
}
}
// Usage
const synchronizer = new InventorySynchronizer('YOUR_TOKEN', 1);
await synchronizer.syncWithLocalSystem(async (sku, quantity) => {
// Update your local database
await db.products.update({ sku }, { chronosStock: quantity });
});
Best Practicesβ
Query Frequencyβ
- Before each order: Always verify stock
- Periodic updates: Every 15-30 minutes for synchronization
- Alerts: Set up hourly checks for critical products
Handling Zero Stockβ
function handleOutOfStock(sku, alternatives = []) {
// Options when there's no stock:
// 1. Search in other warehouses
const searchOtherWarehouses = async () => {
const warehouses = await getAvailableWarehouses();
for (const wh of warehouses) {
const stock = await checkStock(wh.id, sku);
if (stock > 0) return { warehouseId: wh.id, stock };
}
return null;
};
// 2. Suggest alternative products
const suggestAlternatives = () => {
return alternatives.filter(alt => alt.stock > 0);
};
// 3. Allow backorder (if enabled)
const allowBackorder = () => {
return {
message: "Product available for order. Extended delivery time.",
estimatedTime: "7-10 days"
};
};
}
If you need to check multiple SKUs, it's more efficient to make a single query and filter locally instead of making multiple calls per individual SKU.
Stock can change rapidly. Always verify availability just before creating an order, don't rely on cached data for too long.
When you create an order, stock is automatically reserved. If the order is cancelled or not processed, the stock is released after a determined time.