Skip to main content

Walmart IO API python wrapper

Project description

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 location.

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

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

Post Browsed Products

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

data = wiopy.post_browsed_products('54518466')

Response gives top 10 relevent 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 = wiopy.product_lookup('33093101')[0]

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

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, all items will be lost. But the entire call will not be lost.

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

Response gives generator of WalmartProducts

Product Recommendation

Get recommendations based on a given product id

data = wiopy.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 = wiopy.reviews('33093101')

Response gives review data

Search

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

Stores

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)

Taxonomy

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

data = wiopy.taxonomy()

Trending Items

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

data = wiopy.trending()

Logging

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

import logging

logging.basicCongif(level=logging.INFO)

License GitHub last commit

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

WIOpy-0.0.6.tar.gz (16.8 kB view details)

Uploaded Source

Built Distribution

WIOpy-0.0.6-py2-none-any.whl (18.4 kB view details)

Uploaded Python 2

File details

Details for the file WIOpy-0.0.6.tar.gz.

File metadata

  • Download URL: WIOpy-0.0.6.tar.gz
  • Upload date:
  • Size: 16.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for WIOpy-0.0.6.tar.gz
Algorithm Hash digest
SHA256 439193a082ea983b81df65abd6dc04d41556a856ee959279d892682b48202b28
MD5 d909a5d0a8e90f033f2f02500bd731fa
BLAKE2b-256 696a68205446390ec2057f1fbf899b9c905993c4b4a831534613bf5614cf5a2a

See more details on using hashes here.

File details

Details for the file WIOpy-0.0.6-py2-none-any.whl.

File metadata

  • Download URL: WIOpy-0.0.6-py2-none-any.whl
  • Upload date:
  • Size: 18.4 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for WIOpy-0.0.6-py2-none-any.whl
Algorithm Hash digest
SHA256 e9a7590fc456316c89197a388b563fa73b93d83c080dfd78ea3915418e48d782
MD5 d76c3d8eafb024f8705c40badaa4d15b
BLAKE2b-256 bc74acc1310ff3cc2e7522341a9af912f8c61dbaa1c3f38846377758b811e8a4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page