Wapy
🤖 A fully featured, easy to use Python wrapper for the Walmart Open API
Install / Use
/learn @caroso1222/WapyREADME
Wapy
Wapy is a fully featured Python wrapper for the Walmart Open API.
Features
- Easy to use, object oriented interface to the Walmart Open API. (Products and Reviews are retrieved as objects)
- Ready to use, parsed attributes. e.g. prices as
float, no strings with escaped html entities, numbers asint. - Full support for Walmart Search API, Product Recommendation API, Post Browsed Products API, Trending API and more.
- Get all responses with
richAttributes='true'by default. This lets you get weight and dimensions right off the shelf. - Proper error handling according to original Walmart API documentation
- Helper functions such as
bestseller_products()and more from the Special Feeds section. - Silently fails when attribute not found in response
- Fully documented source code
- Support for Python 2.7, 3.2, 3.3, 3.4 and 3.5
Requirements
Before using Wapy, you want to make sure you have requests installed and a Walmart Open API key:
pip install requests- Register and grab your API key in the Walmart Open API Developer portal.
Installation
Installation via pip is recommended:
pip install wapy
You can also install it from source:
git clone https://github.com/caroso1222/wapy
cd wapy
python setup.py install
Basic usage
from wapy.api import Wapy
wapy = Wapy('your-walmart-api-key') # Create an instance of Wapy.
#### PRODUCT LOOKUP ####
product = wapy.product_lookup('21853453') # Perform a product lookup using the item ID.
print (product.name) # Apple EarPods with Remote and Mic MD827LLA
print (product.weight) # 1.0
print (product.customer_rating) # 4.445
print (product.medium_image) # https://i5.walmartimages.com/asr/6cd9c...
#### PRODUCT SEARCH ####
products = wapy.search('xbox')
for product in products:
print (product.name)
#### PRODUCT REVIEWS ####
reviews = wapy.product_reviews('21853453')
for review in reviews:
print (review.reviewer)
This example barely shows the power of Wapy. Read the API documentation to discover all you can achieve with this library.
API documentation
class Wapy
This class models the main Walmart API proxy class and offers services such as product lookup, product search, trending products retrieval, and much more.
Methods
__init__([api_key], **kwargs)
Initialize a Walmart API Proxy.
Params#####
api_keyA string representing the Walmart Open API key. Can be found in 'My Account' when signing in your Walmartlabs account.- Named optional params passed in kwargs:
LinkShareIDYour own LinkShare ID. It can be found in any link you generate from the LinkShare platform after the 'id=' parameter. It is an 11 digit alphanumeric string.
product_lookup([item_id], **kwargs)
Walmart product lookup.
Params
item_idA string representing the product item id.- Named optional params passed in kwargs:
richAttributesA boolean to specify whether you want to get your reponse with rich attributes or not. It's True by default.
Return
An instance of WalmartProduct. <[WalmartProduct]>
search([query], **kwargs)
Search allows text search on the Walmart.com catalogue and returns matching items available for sale online.
This implementation doesn't take into account the start parameter from the actual Walmart specification. Instead, I've abstracted the same concept to a paginated approach. You can specify which 'page' of results you get, according to the numItems you expect from every page.
Params
querySearch text - whitespace separated sequence of keywords to search for- Unnamed params passed in kwargs:
numItemsNumber of matching items to be returned, max value 25. Default is 10.pageNumber of page retrieved. Each page contains [numItems] elements. If no numItems is specified, a default page contains 10 elements.categoryIdCategory id of the category for search within a category. This should match the id field from Taxonomy APIsortSorting criteria, allowed sort types are [relevance, price, title, bestseller, customerRating, new]. Default sort is by relevance.orderSort ordering criteria, allowed values are [asc, desc]. This parameter is needed only for the sort types [price, title, customerRating].responseGroupSpecifies the item fields returned in the response, allowed response groups are [base, full]. Default value is base.facetBoolean flag to enable facets. Default value is off. Set this to on to enable facets.facet.filterFilter on the facet attribute values. This parameter can be set to <facet-name>:<facet-value> (without the angles). Here facet-name and facet-value can be any valid facet picked from the search API response when facets are on.facet.rangeRange filter for facets which take range values, like price. See usage above in the examples.
Return
A list of WalmartProduct instances. <[WalmartProduct]>
####product_recommendations([item_id])
Returns a list of a product's related products. A maximum of 10 items are returned, being ordered from most relevant to least relevant for the customer.
Params
item_idThe id of the product from which the related products are returned
Return
A list of WalmartProduct instances. <[WalmartProduct]>
post_browsed_products([item_id])
Returns a list of recommended products based on their product viewing history. A maximum of 10 items are returned, being ordered from most relevant to least relevant for the customer.
Params
item_idThe id of the product from which the post browsed products are returned
Return
A list of WalmartProduct instances. <[WalmartProduct]>
product_reviews([item_id])
Returns the list of reviews written by Walmart users for a specific item.
Params
item_idThe id of the product which reviews are returned from
Return
A list of WalmartProductReview instances. <[WalmartProductReview]>
trending_products()
Returns a list of items according to what is bestselling on Walmart.com right now. The items are curated on the basis of user browse activity and sales activity, and updated multiple times a day.
Return
A list of WalmartProduct instances. <[WalmartProduct]>
bestseller_products([category])
Return a list of bestselling items in their respective categories on Walmart.com. This method is part of the Special Feeds section of the Walmart API.
Params
categoryThe number id of the category from which the products are retrieved.
Return
A list of WalmartProduct instances. <[WalmartProduct]>
clearance_products([category])
Return a list of all items on clearance from a category. This method is part of the Special Feeds section of the Walmart API.
Params
categoryThe number id of the category from which the products are retrieved.
Return
A list of WalmartProduct instances. <[WalmartProduct]>
special_buy_products([category])
Return a list of all items on Special Buy on Walmart.com, which means there is a special offer on them. This method is part of the Special Feeds section of the Walmart API.
Params
categoryThe number id of the category from which the products are retrieved.
Return
A list of WalmartProduct instances. <[WalmartProduct]>
class WalmartProduct
This class models a Walmart Product as an object. A WalmartProduct instance will be returned when performing a product_lookup from your Wapy instance.
Methods
get_attribute([name])
Returns any of the product attributes from the Full Response group. When using this method to get attribute values, you must parse the response to float or integer whenever needed. I don't recommend accessing attributes using this method. Direct attribute access is preferred. See Atributes section below.
Params
nameProduct attribute's name. Check out the Atributes section below to see allowed names.
Return
The product attribute value. <string>
get_images_by_size([size])
A list with all the images URLs. Primary image is always returned in the first position of the list.
Params
sizeSize of the desired images: possible options are: 'thumbnail', 'medium', 'large'.
Return
List with all the images URLs. <[string]>
Attributes
All properties return None if not found in the Walmart API response.
item_id
A positive integer that uniquely identifies an item. <string>
parent_item_id
Item Id of the base version for this item. This is present only if item is a variant of the base version, such as a different color or size. <string>
name
Standard name of the item. <string>
msrp
Manufacturer suggested retail price. <string>
sale_price
Selling price for the item in USD. <float>
upc
Unique Product Code. <string>
category_path
Product Category path: Breadcrumb for the item. This string describes the category level hierarchy that the item falls under. <string>
category_node
Category id for the category of this item. This value can be passed to APIs to pull this item's category level information. <string>
short_description
Short description for the item. <string>
long_description
Long description for the item. <string>
brand_name
Item's brand name. <string>
thumbnail_image
URL for the small sized image. This is a jpeg image
Related Skills
node-connect
351.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
351.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
351.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
