WalmartIO Python Wrapper – WIOpy
A python wrapper for the Walmart io API. Only supports the Affiliate API for now. The project is open to contributions
To download WIOpy, either fork this github repo or simply use Pypi via pip.
$ pip install WIOpy
To upgrade the package simply run
$ pip install WIOpy --upgrade
How to use
An example of creating a WIOpy connection
from wiopy import WalmartIO wiopy = WalmartIO(private_key_version='1', private_key_filename='./WM_IO_private_key.pem', consumer_id='XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX') data = wiopy.product_lookup('33093101')
When making a call to the API, an object will be returned. That object is an object version of returned JSON.
There are two ways to get info from the object:
An example of a returned object and one that is not (review/search are variables returned):
review.reviewStatistics.averageOverallRating# Nested call
search.facets# Gives back a dict that can now be used like a dict and not object
Some attributes will return a dict and not an object due to a lack of documentation from Walmart.
When getting an attribute from a
WalmartResponse, it will return either
None. But trying to get an attribute of
Nonewill still raise an error.
Extra details on calls and responses. However, the docs are inconsistent and lack typical practices such as response schema. That is why something like the search facets response is missing because the docs show it is in the response but not what type of data it will contain.
While there may be a response missing or a response not being converted to an object, please check WalmartResponse to get an idea of what a response will return. Some properties are not always present in a response.
Examples of calls
Catalog Product API allows a developer to retrieve the products catalog in a paginated fashion. Catalog can be filtered by category, brand and/or any special offers like rollback, clearance etc.
data = wiopy.catalog_product()
A catalog response contains category, format, nextPage, totalPages, and a list of items
The post browsed products API allows you to recommend products to someone based on their product viewing history.
data = wiopy.post_browsed_products('36904791')
Response gives top 10 relevent items to the given id
There are two ways to lookup a product
The first is to pass a single string in
data = wiopy.product_lookup('33093101')
or you can pass a list of strings
data = wiopy.product_lookup('33093101, 54518466, 516833054') data = wiopy.product_lookup(['33093101', '54518466', '516833054'])
Remember: product_lookup always returns a list of WalmartProducts
Get recommendations based on a given product id
data = wiopy.product_recommendation('36904791')
Response gives a list of related products
The Reviews API gives you access to the extensive item reviews on Walmart that have been written by the users of Walmart.com
data = wiopy.reviews('33093101')
Response gives review data
Search API allows text search on the Walmart.com catalogue and returns matching items available for sale online.
# Search for tv within electronics and sort by increasing price: data = wiopy.search('tv', categoryId='3944', sort='price', order='ascending')
You can also add facets to your search
data = wiopy.search('tv', filter='brand:Samsung')
The search response gives back a list of products and some meta data. It returns a
facets element but there is no detail on the API about what it could return. It is a list of some unknown type
The API can return a list of closest stores near a specified location. Either zip code or lon/lat
data = wiopy.stores(lat=29.735577, lon=-95.511747)
The taxonomy service exposes the taxonomy used to categorize items on Walmart.com.
Details about params is missing from docs
data = wiopy.taxonomy()
The Trending Items API is designed to give the information on what is bestselling on Walmart.com right now.
data = wiopy.trending()