Articles and stock
Listing articles
cURL
curl -X POST http://localhost:4000/NextUpServices/Services/POST/ \
-H "Content-Type: text/plain" \
-d "{\"AuthenticationToken\":\"$NX_TOKEN\",\"Method\":\"GetAllArticles\",\"Params\":{}}"
Adding an article
Node.js
const newArticle = await client._call('AddArticle', {
Code: '0000010',
Name: 'Advanced consulting services',
VATRateId: 1, // 19% VAT
UnitOfMeasure: 'ORA',
IsService: true,
SalePrice: 350.00
});
Searching by name or code
Python
results = nx_call(token, 'GetArticlesByNameAndCode', {'name': 'laptop'})
# Returns all articles whose name contains "laptop"
Stock
cURL
# All stock (all articles × all warehouses)
curl -X POST http://localhost:4000/NextUpServices/Services/POST/ \
-H "Content-Type: text/plain" \
-d "{\"AuthenticationToken\":\"$NX_TOKEN\",\"Method\":\"GetAllStocksForArticles\",\"Params\":{}}"
# For a single article only
curl -X POST http://localhost:4000/NextUpServices/Services/POST/ \
-H "Content-Type: text/plain" \
-d "{\"AuthenticationToken\":\"$NX_TOKEN\",\"Method\":\"GetStocksForArticleByCode\",\"Params\":{\"code\":\"0000002\"}}"
Checking availability before an order
Node.js — a useful pattern
async function checkAvailability(client, articleCode, qty, warehouseId) {
const stocks = await client._call('GetStocksForArticleByCode', { code: articleCode });
const inWh = stocks.find(s => s.WarehouseId === warehouseId);
if (!inWh) return { available: 0, ok: false };
const available = inWh.Quantity - inWh.ReservedQuantity;
return { available, ok: available >= qty };
}
const check = await checkAvailability(client, '0000002', 5, 1);
if (!check.ok) {
console.warn(`Only ${check.available} units available`);
}