yoavaviram / python-amazon-simple-product-api Goto Github PK
View Code? Open in Web Editor NEWA simple Python wrapper for the Amazon.com Product Advertising API ⛺
License: Apache License 2.0
A simple Python wrapper for the Amazon.com Product Advertising API ⛺
License: Apache License 2.0
>>>products = amazon.lookup(ItemId='B0051QVESA,B005DOK8NW,B005890G8Y,B0051VVOB2,B005890G8O')
>>> len(products)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: object of type 'AmazonProduct' has no len()
Does the application provide a way to query a specific result page without iterating through the previous pages first? I see the Amazon products advertising API supports that. http://docs.aws.amazon.com/AWSECommerceService/latest/DG/PagingThroughResults.html
amazon = AmazonAPI(AMAZON_ACCESS_KEY, AMAZON_SECRET_KEY, AMAZON_ASSOC_TAG)
On eBooks all I get for product.price_and_currency
is (None, None)
.
Trying with books everything runs fine.
Is it an API issue or an Amazon issue?
Offer_url of AmazonProduct ignores the region givent at the construction of AmazonAPI when using "search_n" method.
So the offer_url is always "amazon.com"...
result = amazon.browse_node_lookup(ResponseGroup="TopSellers",BrowseNodeId=1)
The topSellers and topItemSet return only 1 element in result ,but the right is more
more:http://docs.aws.amazon.com/AWSECommerceService/2011-08-01/DG/RG_TopSellers.html
Hi,
When I run tests, the test case TestAmazonCart.test_cart_modify
always fails. Although this does not affect my product code, this gets in the way of supporting Python 3, ref. #77. In my environment, the test case fails both in Python 2 and 3. @yoavaviram, could you tell me does it succeed in your environment?
All the tests succeed.
Only one test case TestAmazonCart.test_cart_modify
always fails. Other tests succeed.
(venv2)$ nosetests
...................................E
======================================================================
ERROR: test_cart_modify (tests.TestAmazonCart)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/Users/orange/github-libs/python-amazon-simple-product-api/tests.py", line 459, in test_cart_modify
assert_equals(new_cart[cart_item_id].quantity, '3')
File "/Users/orange/github-libs/python-amazon-simple-product-api/amazon/api.py", line 1312, in __getitem__
raise KeyError('no item found with CartItemId: {0}'.format(cart_item_id,))
KeyError: 'no item found with CartItemId: C8AIO6HTRFXA6'
-------------------- >> begin captured logging << --------------------
bottlenose.api: DEBUG: Amazon URL: http://webservices.amazon.com/onca/xml?...
--------------------- >> end captured logging << ---------------------
----------------------------------------------------------------------
Ran 36 tests in 36.346s
FAILED (errors=1)
(venv2)$ python -V
Python 2.7.11
(venv2)$ pip freeze
bottlenose==0.6.3
docutils==0.12
funcsigs==1.0.2
Jinja2==2.8
lxml==3.6.0
MarkupSafe==0.23
mock==2.0.0
nose==1.3.7
pbr==1.10.0
Pygments==2.1.3
python-dateutil==2.5.3
six==1.10.0
Sphinx==1.1.3
wheel==0.24.0
You are using pip version 7.1.2, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
It seems that the latest version via pip is 1.5.0
please bump to latest version
I want to search Amazon using UPC code instead of ASIN. Could any one help me on this please.
Try this product for example:
http://www.amazon.com/Apple-Fully-Speced-3-4GHz-256GB/dp/B004YLCBRG
AttributeError: 'NoneType' object has no attribute 'asin'
So far the API looks great. I was hoping to use the Similarity Lookup as well with the API. Any chance you can implement it?
Documentation is here:
http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/SimilarityLookup.html
I would write an implementation and push it but I am in the process of learning python and I fear it would take me several hours to implement, and would probably take you 15 minutes to implement. If you don't have time I can look into implementing it and making a pull request over the next few weeks.
Thanks!
Hi,
The detail_page_url
of AmazonProduct
class has been removed. Any reason for this change please?
Also, on pypi the version of the package is python-amazon-simple-product-api==1.5.0 for the "version" which had detail_page_url
and the one I just downloaded (using pip install -r requirements.txt
) in which detail_page_url
have been removed.
Thanks and regards.
hello, could you please port the code to support py3, you have no contributing doc, I can help if you need?
can i search a book according it's isbn using your api?
Is there a way to do a search for multiple items in a single request (batch requests)?. This is very important because of amazon's one second rule. It does look like some one has implemented it elsewhere as I found this forum post.
Why do you divide by 100 the Japanese price? I'm getting 11,00 JPY instead of 1100 JPY, that is the correct price.
For example, in laptop page, we can narrow by hard drive size, memory size and so on.
Thanks.
I don't believe to see quantity as a call to be made once a product is generated? Or am I missing something?
So far I got everything up and running to the way I like it. The only thing I have left to figure out is how to check if the item I am looking at has prime or not. Can this be done? I am hoping so, since you can pull price etc already. Basically just need it to say Yes/ No for prime; Yes if it finds the prime text/icon and No if it is missing from the listing.
I would appreciate any help on this, thanks again for this!
I realized this uses bottlenose which doesnt support Python 3. Has this package been written to work with Python 3? Or does that still have to be implemented? Thanks for this btw.
Hi,
Is there a way to find availability of the product. Product availability in the response xml is under 'Offers.Offer.OfferListing.AvailabilityAttributes.AvailabilityType' element.
Thanks
While following the Readme instructions
bn = amazon.browse_node_lookup(BrowseNodeId=2642129011)
gives HTTP 400 error
Can you please upload the recent version to pypi?
I'm new to amazon api, I wrote a simple code. I run into 503 Error very often. just a retry will be ok.
should this module retry when service Unavailable?
LM-SHC-00950567:~ zhifan$ python a.py
0. '亚马逊Kindle电子书阅读器'
Hi, in my app i handle the request with bottlenose already (modified version of bottlenose) ...
is it possible to pass the string result to you api ? so i will have in return the object ?
Thanks
Hi there!
How do I get the description of a product and the link to the its detail page?
Best,
Carl
Seems to happen during paging, so I can't easily catch it in my app.
I'm using this to search for MP3s. In this the XML contains a RelatedItems sections, this is where the album title is stored. I see it when I to_string() to product, but I can't figure out how to access it.
Dear Yoav,
I followed all instructions to install the API on a Mac running OSX 10.11.4
All components (boottlenose, lxml, dateutil and the API itself were properly installed.
Yet, when attempting to follow one example I get the following response:
I am certain the access, secret and associate keys are correct.
My reading of the error messages is that the arguments are not flowing correctly across the code. But have not been able to figure out a solution.
Could you please update the version on PyPi with the new kwargs from #38 and any other fixes since then?
Cheers
other than title and price which other attributes can i get? for example - description, link to the actual product ( not its image ), shipping charges etc
hi
i cant make a pagination, amazon returns 10 pages and this is not a good solution when it's blocking code :(
hope this features will be enabled.
When I try looking up a product on US it works. But when I try to set the region to CA It returns even if the ItemID does exist on amazon.ca:
urllib.error.HTTPError: HTTP Error 400: Bad Request
If I test on other regions, it also still works. (assuming the id is valid) So it appears to only not work on canada.
hi, the md5 for python lxml is wrong when fetching it, using open suse here, i must install it alone.
Hi, thanks for the nice API!
I ran into a simple paging issue.
The following code
p = a.search(SearchIndex='Books', Author='john grisham', Power='pubdate:after 2014 and pubdate:before 2016')
for pp in p:
print pp.release_date, '========', pp.title
seems to fail to understand paging, ultimately I get a 503. Here's more info though. I added some code in bottlenose/api.py, more specifically in _call_api() to print the first api_url param, and here's what I get (I stripped the noise in the URLs after the first one to highlight the problem):
http://ecs.amazonaws.com/onca/xml?AWSAccessKeyId=...&AssociateTag=...&Author=john%20grisham&ItemPage=1&Operation=ItemSearch&Power=pubdate%3Aafter%202014%20and%20pubdate%3Abefore%202016&ResponseGroup=Large&SearchIndex=Books&Service=AWSECommerceService&Timestamp=...&Version=2011-08-01®ion=US&Signature=...
2015-05-12 ======== Theodore Boone: The Fugitive
2015-05-19 ======== Theodore Boone Box Set
2015-02-21 ======== The man from the fog
http://ecs.amazonaws.com/onca/xml?...ItemPage=2&...
http://ecs.amazonaws.com/onca/xml?...ItemPage=3&...
http://ecs.amazonaws.com/onca/xml?...ItemPage=4&...
http://ecs.amazonaws.com/onca/xml?...ItemPage=5&...
http://ecs.amazonaws.com/onca/xml?...ItemPage=6&...
http://ecs.amazonaws.com/onca/xml?...ItemPage=7&...
http://ecs.amazonaws.com/onca/xml?...ItemPage=8&...
http://ecs.amazonaws.com/onca/xml?...ItemPage=9&...
http://ecs.amazonaws.com/onca/xml?...ItemPage=10&...
http://ecs.amazonaws.com/onca/xml?...ItemPage=11&...
Traceback (most recent call last):
File "amzn.py", line 4, in
for pp in p:
File "/usr/lib/python2.6/site-packages/amazon/api.py", line 234, in iter
for page in self.iterate_pages():
File "/usr/lib/python2.6/site-packages/amazon/api.py", line 250, in iterate_pages
yield self._query(ItemPage=self.current_page, *_self.kwargs)
File "/usr/lib/python2.6/site-packages/amazon/api.py", line 263, in _query
response = self.api.ItemSearch(ResponseGroup=ResponseGroup, *_kwargs)
File "/usr/lib/python2.6/site-packages/bottlenose/api.py", line 243, in call
{'api_url': api_url, 'cache_url': cache_url})
File "/usr/lib/python2.6/site-packages/bottlenose/api.py", line 204, in _call_api
return urllib2.urlopen(api_request, timeout=self.Timeout)
File "/usr/lib64/python2.6/urllib2.py", line 126, in urlopen
return _opener.open(url, data, timeout)
File "/usr/lib64/python2.6/urllib2.py", line 397, in open
response = meth(req, response)
File "/usr/lib64/python2.6/urllib2.py", line 510, in http_response
'http', request, response, code, msg, hdrs)
File "/usr/lib64/python2.6/urllib2.py", line 435, in error
return self._call_chain(_args)
File "/usr/lib64/python2.6/urllib2.py", line 369, in _call_chain
result = func(_args)
File "/usr/lib64/python2.6/urllib2.py", line 518, in http_error_default
raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 503: Service Unavailable
So somehow amazon/api.py keeps iterating forever (it even goes beyond the hard page limit 10) even though the first ItemPage returned only 3 results (as I can tell by copy/pasting the first URL in my browser) and that should be the end.
I see there's search_n() but ultimately all I want is to return all the results of my search query, not the top N.
Even with the SalesRank
response group I can't get the SalesRank
attribute.
When the API can`t find anything from search it terminates the program. Is there a way to handle the callback and just go to the next search in the list?
I'm getting this error: HTTPError: HTTP Error 400: Bad Request
while using
product = amazon.lookup(ItemId='B00IUICOF8')
ps: I'm using python 2.7
Using float for prices can lead to precision issues.
The way this project currently works is by assuming there's only one response group ("Large"). The Product
class is based on that response group, plus a few extras which are relevant to different ResponseGroups.
We should majorly refactor this to address different ResponseGroups and allow easy access to their fields (or Resposne Elements, as named by Amazon).
Reference for ResponseGroup can be found here, with the valid values:
http://docs.aws.amazon.com/AWSECommerceService/latest/DG/ItemLookup.html
I'll be adding a few fields to the Product
class meanwhile, but will try to iterate on creating a class that'll handle multiple response groups, or a class for each response group.
For some reason when trying to use power searching (http://docs.aws.amazon.com/AWSECommerceService/latest/DG/PowerSearchOperators.html)
This script returns no results. It seems that the "or" logic is not working as I would expect it to. Has anyone else experienced this?
from amazon.api import AmazonAPI
amazon = AmazonAPI('secret', 'secret', 'secrettag)
products = amazon.search_n(6,Keywords='bottle OR gear OR tree or coffee or house or melon',SearchIndex='Apparel',Sort='relevancerank')
Hi guys,
I know its a silly question. But its taking a quite a lot of time to figure it out. When i use the below script, i could able to get only 50 products and not more than that. but when i checked for products.current_page, i can see the value is '6'. I'm not sure how to iterate other products after that. Please help me with a good example to get the list of all the products available using search method. If not suggest me any other way of doing it.. Thanks in Advance.
from amazon.api import AmazonAPI
amazon = AmazonAPI(AMAZON_ACCESS_KEY, AMAZON_SECRET_KEY, AMAZON_ASSOC_TAG)
products = amazon.search(Keywords='kindle', SearchIndex='All')
for i, product in enumerate(products):
print "{0}. '{1}'".format(i, product.title)
I'm running the example code for batch item lookups
from amazon.api import AmazonAPI
amazon = AmazonAPI('XXX', 'XXX', 'XXX')
products = amazon.lookup(ItemId="B0051QVESA,B005DOK8NW,B005890G8Y,B0051VVOB2,B005890G8O")
len(products)
and i'm getting the following error
TypeError: object of type 'AmazonProduct' has no len()
Am I doing something wrong ?
After installing this package I am not able to create or use scrapy(http://scrapy.org/) projects with the name 'amazon'.
For Books Amazon provides Power Search but I could't make it. Could you show a sample or provide new feature for Power Search?
http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/PowerSearchSyntax.html
I've installed bottlenose and lxml using pip. Pip installed lxml 3.2.3, which I thought would be fine (I didn't see a version specified). Turns out this is not the case. When I attempt to import AmazonAPI I get the error "No module named lxml".
Right now I can only seem to access the text of elements with get_attributes. Is there a way to access the attributes of these elements? Specifically I'm trying to access the Units attribute of ItemDimensions.Weight
The following product fails to have it's publication date parsed correctly. ASIN 0933635869.
The date is in the 'Item' data is the format "PublicationDate": "1992-05",
The resulting value in product.publication_date
is None
.
The dateutil library is able to parse dates like this, its probably worth using it instead.
>>> import dateutil.parser
>>> dateutil.parser.parse('1992-05')
datetime.datetime(1992, 5, 15, 0, 0)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.