CS 320 XML WVUP Fall 2016
To install, first you need to add this line in your package.json file under the dependencies
"walmart": "git+https://github.com/zroberts/walmart.git"
Next, run npm install and it should pull down the files and install them.
var walmart = require("walmart");
walmart.setApi(<API KEY>);
##########
walmart.search(<searchObject>, function(err, res){
});
searchObject is a JSON Object, with searchTerm required, minPrice and maxPrice optional
var searchObject = {
searchTerm : 'Playstation',
minPrice : '100',
maxPrice : '200'
}
will return an array of json object with the following fields
[
{
id: <the product ID>,
name: <the product name>,
price: <msrp>,
saleprice: <current price>,
category: <category parth from walmart>,
url: <URL to product on Walmart.com>,
imageUrl: <url for the medium-sized image>,
provider: <STATIC Walmart>,
reviews: <number out of 5, returns 0 if there are no reviews>,
numReviews: <number of reviews that have been submited>,
description: <description of the item>,
}
]
resp[i].id
resp[i].namne
etc...
var walmart = require('walmart');
walmart.setApi(<YOUR_API_KEY>);
var searchObject = {
searchTerm : 'Playstation',
minPrice: '25',
maxPrice: '100'
}
walmart.search(searchObject, function(err, res){
if(err){
console.log(err);
}else{
console.log(res);
}
});