Uploading via HTTP (JSON)
The JSON API allows you to upload stock updates as they happen, for the most real-time integration with NearSt. Stock updates will be processed within seconds, and pushed to the NearSt channels.
Note: At the moment, we recommend using the JSON API for real-time stock updates in combination with uploading a full stock feed through the FTP gateway or HTTP CSV upload endpoints every 24 hours, to ensure products with limited stock moments don't expire (NearSt stops showing any products it hasn't received updates for in the last 7 days).
put
https://stock.near.live
/inventory
Send one or more real-time stock updates
{
"inventory": [
{
"barcode": "123456789012",
"quantity": 13,
"price": 5.99,
"currency": "USD"
}
]
}
cURL:
curl --request PUT 'https://stock.near.live/inventory' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {token}' \
--data-raw '{"inventory":[{"barcode":"123456789012","quantity":13,"price":5.99}]}'
Node.js using Axios:
const axios = require('axios');
async function uploadToNearSt(uploadKey, inventory) {
const config = {
method: 'put',
url: `https://stock.near.live/inventory`,
headers: {
'Authorization': `Bearer ${uploadKey}`
},
data: {inventory}
};
await axios(config);
};
// Example:
const inventory = [
{
barcode: '123456789012',
quantity: 13,
price: 5.99,
currency: 'USD'
}
];
await uploadToNeartSt(myUploadKey, inventory);
Last modified 1yr ago