Coder Social home page Coder Social logo

walmart's Introduction

pymart usage

This API wrapper is still unfinished, but is still very useful. I am using it currently. Feel free to contribute.

To begin using the API, you will need your private_key, consumer_id and channel_type. These are all provided by walmart once you have a seller account.

Retrieve Item Information

We can ask for single item information, or for information in bulk.

Single Item

import pymart
w = pymart.Walmart(private_key, consumer_id, channel_type)
r = w.get_item('some_sku_123')
r.content       # The xml data string

I'm using the requests library to make requests, and what is returned is the Request object.

Bulk Item

import pymart
w = pymart.Walmart(private_key, consumer_id, channel_type)
r = w.get_all_items(offset=0, limit=20)
r.content       # The xml data string

You will have to do this many times to get all of your items, if you have many of them.

Bulk Item (with feeds)

We can also get our items and information from a feed, which returns a csv file.

import pymart
w = pymart.Walmart(private_key, consumer_id, channel_type)
r, data = w.get_item_report(cleaned=True)
# data looks something like [[headers], [row], [row], ...]

Here, r is again the Request object, and data is a list of lists. It looks like what would be returned by csv.reader(f).

Orders

Similarly, we can retrieve order information.

Single Order

import pymart
w = pymart.Walmart(private_key, consumer_id, channel_type)
r = w.get_order('123456789') # arg is purchase order id
r.content # xml data string

Bulk Orders

For some reason, the Walmart API does not provide a way to filter orders by modified_date, so you'll have to do with created_start_date and created_end_date...

import pymart
w = pymart.Walmart(private_key, consumer_id, channel_type)
r = w.get_all_orders(created_start_date='<Some ISO 8601 DateTime>', status='Created', limit=200)
r.content # xml data string

If there are more than 200 orders in the response, then a nextCursor element will be provided and you can provide that as the sole argument to the get_all_orders() method to retrieve the next batch of orders. There are more possible arguments to this method, take a look at the source if you need to filter your results further.

Lastly

There are a few more methods I have provided that will return an XML data string through r.content. I would suggest just looking through the source code of pymart.py. It's pretty easy to read and add on to. If you add onto it, just mimic how I "signed" the requests in other methods. That authorization signature was the most annoying part of writing this wrapper. Hope this is useful to someone.

walmart's People

Contributors

brianjp93 avatar

Stargazers

 avatar jasonli avatar Colter Bowman avatar

Watchers

James Cloos avatar  avatar  avatar

walmart's Issues

License Missing

Can you please provide a license for your code like MIT or BSD so that people can use it. No one has the right to use your code until you do so.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.