redtoad / python-amazon-product-api

A Python wrapper for the Amazon Product Advertising API. This module offers a light-weight access to the latest version of the Amazon Product Advertising API without getting in your way.
https://pypi.org/project/python-amazon-product-api/
BSD 3-Clause "New" or "Revised" License
3 stars 4 forks source link

Item Lookup fails on anything other than ASIN #10

Closed redtoad closed 14 years ago

redtoad commented 14 years ago

Originally reported by Anonymous


Anything other than ASIN fails. If you use the sample example in the quickstart:

root = api.item_lookup('987311264224', IdType='ISBN', SearchIndex='Books')

You'll receive:

/tmp/python-amazon-product-api-0.2.3/amazonproduct.pyc in item_lookup(self, id, **params)
    347             url = self._build_url(Operation='ItemLookup', ItemId=id, **params)
    348             fp = self._call(url)
--> 349             return self._parse(fp)
    350         except AWSError, e:
    351 

/tmp/python-amazon-product-api-0.2.3/amazonproduct.pyc in _parse(self, fp)
    316             if error.Code.text == 'AWS.InvalidParameterValue':
    317                 m = INVALID_PARAMETER_VALUE_REG.search(error.Message.text)
--> 318                 raise InvalidParameterValue(m.group('parameter'), m.group('value'))
    319 
    320             if error.Code.text == 'AWS.RestrictedParameterValueCombination':

InvalidParameterValue: ('ItemId', '987311264224')

redtoad commented 14 years ago

Original comment by Sebastian Rahlf (Bitbucket: basti, GitHub: basti)


I am marking this issue as //invalid// because the API does what it's supposed to do. Amazon simply seems to keep data separate for each locale - which makes sense somehow for different countries and languages.

If you have any problems with using the API, a better place to ask is the mailing list: http://groups.google.com/group/python-amazon-product-api-devel

redtoad commented 14 years ago

Original comment by Sebastian Rahlf (Bitbucket: basti, GitHub: basti)


Use valid ISBN-13 in your example (see #10)!

redtoad commented 14 years ago

Original comment by Sebastian Rahlf (Bitbucket: basti, GitHub: basti)


This API supports UPC. If it doesn't work, use a different locale. "us" should work in your case.

redtoad commented 14 years ago

Original comment by Anonymous


Does this support UPC as well?

I attempted to lookup a product via UPC such as: 883585179497, with IdType='UPC' but to no avail.

redtoad commented 14 years ago

Original comment by Sebastian Rahlf (Bitbucket: basti, GitHub: basti)


First of all, I took a bogus ISBN-13 (with only 12 digits instead of 13) as an example.

However, when looking into this I discovered that the API returns an InvalidParameterValue error if you enter a "wrong" ISBN. Wrong, as it seems, can mean the format is wrong (too short) or or contains invalid characters (dashes "-"). Much to my surprise, wrong can even mean that you used the wrong locale!

For instance, you cannot retrieve data for an English book (ISBN 9780596158064) from locale "de" or for a German book (ISBN 9783836214063) from locale "us" - but using locale "uk" works for both!

Try your query again using a valid ISBN and play around with the locale. You can set the locale at initialisation:

#!python
from amazonproduct import API
AWS_KEY = '...'
SECRET_KEY = '...'
api = API(AWS_KEY, SECRET_KEY, "uk")
# ...