Skip to main content

Python PyPI GitHub release (latest by date including pre-releases) GitHub issues GitHub Repo stars

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

Getting it

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 One important note is that you need to pass in the private key file path.

from wiopy import WalmartIO
walmart_io = WalmartIO(
    private_key_version="1",
    private_key_filename="./WM_IO_private_key.pem",
    consumer_id='XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
    publisherId="XXXXXXX",
)
data = walmart_io.product_lookup('33093101')[0]

WIOpy also supports asynchronous calls. To use, everything will be the same but you must await a call and the constructed object is different.

from wiopy import AsyncWalmartIO
async_walmart_io = AsyncWalmartIO(...)
data = await async_walmart_io.product_lookup('33093101')[0]

Response Examples

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:

  • data.name
  • data['name']
    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 response or None. But trying to get an attribute of None will 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

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 = walmart_io.catalog_product(category='3944', maxId='8342714')

A catalog response contains category, format, nextPage, totalPages, and a list of items

The returned API data is paginated. To get the next page, pass in data.nextPage as a kwarg. All other kwargs will be stripped out. They will be embed in the nextPage response.

data = walmart_io.catalog_product(category="3944", maxId="8342714")
next_data = walmart_io.catalog_product(nextPage=data.nextPage)
# or
next_data = walmart_io.catalog_product(category="3944", maxId="8342714", nextPage=data.nextPage) 

Post Browsed Products

The post browsed products API allows you to recommend products to someone based on their product viewing history.

data = walmart_io.post_browsed_products('54518466')

Response gives top 10 relevant items to the given id

Product lookup

There are two ways to lookup a product The first is to pass a single string in

data = walmart_io.product_lookup('33093101')[0]

or you can pass a list of strings

data = walmart_io.product_lookup('33093101, 54518466, 516833054')
data = walmart_io.product_lookup(['33093101', '54518466', '516833054'])

Remember: product_lookup always returns a list of WalmartProducts

Bulk product lookup

bulk_product_lookup is similar to product_lookup however, the bulk version does not raise errors and it is a generator.
Items are passed in as chunks of max size 20. If an error occurs on that call, the same call will be retried based on the given amount. If error still occurs, all items will be lost. But the entire call will not be lost.

data = walmart_io.bulk_product_lookup('33093101, 54518466, 516833054', amount=1, retries=3)
for items in data:
    for item in items:
        print(item)

Response gives generator of WalmartProducts
If you are unfamiliar with async generators; to properly call the async version:

data = async_walmart_io.bulk_product_lookup('33093101, 54518466, 516833054')
async for items in data:
    ...

Product Recommendation

Get recommendations based on a given product id

data = walmart_io.product_recommendation('54518466')

Response gives a list of related products

Reviews

The Reviews API gives you access to the extensive item reviews on Walmart that have been written by the users of Walmart.com

data = walmart_io.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 = walmart_io.search('tv', categoryId='3944', sort='price', order='ascending')

You can also add facets to your search

data = walmart_io.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

Stores

The API can return a list of closest stores near a specified location. Either zip code or lon/lat

data = walmart_io.stores(lat=29.735577, lon=-95.511747)

Taxonomy

The taxonomy service exposes the taxonomy used to categorize items on Walmart.com.
Details about params is missing from docs

data = walmart_io.taxonomy()

The Trending Items API is designed to give the information on what is bestselling on Walmart.com right now.

data = walmart_io.trending()

Logging

WIOpy supports logging via the logging module. Configuration of the logging module can be as simple as:

import logging

logging.basicConfig(level=logging.INFO)

License GitHub last commit

Metadata

Release files for wiopy 1.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wiopy 1.2.2
File Size Uploaded
wiopy-1.2.2.tar.gz 18.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for wiopy 1.2.2
File Interpreter ABI Platform
wiopy-1.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 45.5 kB

Release files / wiopy-1.2.2.tar.gz

Download URL wiopy-1.2.2.tar.gz
Size 18.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a2936e560802c9f75e476c484b6b8dfa133db28d6c4fb63cf5d4421cc71d91e2
BLAKE2b-256 checksum
How to use checksums
0a3871877dec399eb0adf386dfa794169fe0039320277413ab20e7b5386c9030
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.0

Release files / wiopy-1.2.2-py3-none-any.whl

Download URL wiopy-1.2.2-py3-none-any.whl
Size 27.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
abbe2b943845f9ea47971e81067369267e6d7ddae27ae53500ff3ca53f764d05
BLAKE2b-256 checksum
How to use checksums
9926bfca6ec2599421ebf7c2416a64babdaa5566a10d4387c0f2339ece306be5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.8.0

Release history Release notifications | RSS feed

This release

1.2.2 This release

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.1

2 release files

0.1.1

2 release files

0.0.9

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page