WebService::Walmart - Generic API to Walmart Labs Open API
WebService::Walmart is an experimental Perl interface to the Walmart Open API. While this module will attempt to implement the full API, the Walmart API is in heavy development, and this module is still figuring out how to implement it.
In order to use the API, you will need to sign up for an account and get an API key located at https://developer.walmartlabs.com/
NOTE: This is an EXPERIMENTAL release. The methods are subject to change. Walmart will most likely change their data structures as they implement more of the API.
In order to use the methods below, you will first need to create an instance of this module to work with.
my $walmart = WebService::Walmart->new( api_key => '123456781234567812345678', format => 'json', debug => 0, );
Every method in this module currently throws a fatal exception WebService::Walmart::Exception on failure. You will either want to wrap method calls with an eval statement or use something like Try::Tiny or Try::Catch.
my @stores = $walmart->stores( lat => 'latitude', lon => 'longitude', city => 'City Name', zip => zipcode, );
Search the API for stores with the criteria supplied and return an array containing objects of WebService::Walmart::Store for stores based upon Latitude/Longitude, City Name, or Zipcode. More information on the response data can be found at https://developer.walmartlabs.com/docs/read/Store_Locator_API
Example:
my @stores = $walmart->stores( zip=> 72716); print $stores[0]->phoneNumber;
my $item = $walmart->item( id => itemid);
This method will search for an item based upon ID and return a scalar object containing WebService::Walmart::Item.
my $item = $walmart->items( id => 42608121); print $item->name;
$walmart->reviews( id => itemid );
This method will retrieve the reviews for an item based up on ID and return an array of WebService::Walmart::Review. Example:
my @reviews = $walmart->reviews({ id => '42608121'}); print $review[0]->name;
$walmart->search( query => 'string', # a string to search for categoryId => 1234, # a Category ID to search for. This should match the ID in the WebService::Walmart::Taxonomy package facet => 'string', # enable facets facet.filter => 'string', # filter to apply to the facets );
This method will search for items and return an array of Webservice::Walmart::Item. Example:
my @items = $walmart->search({ query => 'ipod'}); print "the first item has ". $search[0]->numReviews . " reviews to read!\n";
$walmart->vod();
This method will return the value of the day in scalar format. It will return a WebService::Walmart::Item object. Example:
my $vod = $walmart->vod(); print "Today's Value of the Day is ". $vod->name . "\n";
$walmart->trends();
Returns trending items on Walmart.com. This will be an array of WebService::Walmart::Item objects. Example:
my @trends = $walmart->trends(); print "The big name in today's trends are ". $_->name . "\n" foreach @trends
$walmart->taxonomy();
Returns a WebService::Walmart::Taxonomy objects as an array. This is how Walmart.com categorizes items. Example:
my @taxonomy = $walmart->taxonomy(); use Data::Dumper; print Dumper @taxonomy;
There will likely be many. Please file a report and I'll fix it as soon as possible.
https://developer.walmartlabs.com/
To install WebService::Walmart, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WebService::Walmart
CPAN shell
perl -MCPAN -e shell install WebService::Walmart
For more information on module installation, please visit the detailed CPAN module installation guide.