pythonamazon-web-servicesamazon-product-api

Checking trade in value for video games


I'm trying to get the trade in value on a video game using the python amazon api. http://python-amazon-product-api.readthedocs.org/en/latest/

I have tried running this code:

from amazonproduct import API
api = API(locale='us')
items = api.item_search('VideoGames', Keywords='Metal Gear Solid',IsEligibleForTradeIn ='1')
for item in items:
    if item.ItemAttributes.TradeInValue.Amount:
            print '%s: %d' % (item.ItemAttributes.Title, item.ItemAttributes.TradeInValue.Amount)

But I get an AttributeError claiming there is no such child "TradeInValue"

This code works until I ask for trade in value, is tradeInValue a valid attribute for video games?

EDIT: Print out for print item.__dict__

{'ItemAttributes': <Element {http://webservices.amazon.com/AWSECommerceService/2011-08-01}ItemAttributes at 0x7f7a1b117128>, 'ASIN': 'B00JKM06HG', 'ItemLinks': <Element {http://webservices.amazon.com/AWSECommerceService/2011-08-01}ItemLinks at 0x7f7a1b1177e8>, 'DetailPageURL': 'http://www.amazon.com/Metal-Gear-Solid-Phantom-Pain-PlayStation/dp/', 'ParentASIN': 'B00KVVSONI'}

Solution

  • After researching some of the info provided by you and the docs for item_search and item_lookup

    It looks like item_lookup (and I presume item_search) can return some or all of the attributes, depending on the response group specified in the request. By default, item_lookup, returns an item’s ASIN, Manufacturer, ProductGroup, and Title of the item.

    While going through the available ResponseGroups on AWS, I discovered ItemAttributes, which also returns TradeInValue as described here. I don't have an Amazon Developer account set up, however, you could try changing your search parameters to the below (and see if the additional attributes show up)

    items = api.item_search(
        'VideoGames',
        Keywords='Metal Gear Solid',
        IsEligibleForTradeIn='1',
        ResponseGroup='ItemAttributes'
    )