Giter VIP home page Giter VIP logo

python-amazon-paapi's People

Contributors

ak4zh avatar b0lle avatar barbax7 avatar blob810 avatar fijter avatar gutfeeling avatar orangain avatar patrickdessalle avatar sergioteula avatar viktorfa avatar ypcrumble avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-amazon-paapi's Issues

Allow the user to disable throttling, or to set throttling to a value greater than one.

I believe my understanding is correct that the maximum requests per second currently is one request per second? For users with a higher rate limit it would be ideal to be able to either turn off throttling or set throttling to a number greater than one.

I suggest allowing any positive number to allow more requests per second, and to allow 0 or False to disable throttling altogether.

Happy to make a PR at some point when I find time if this makes sense and would be helpful!

Exception handling

We want to implement specific operations for each different exception, but currently cannot do that e.g

amazon.exception.AmazonException: ApiException: (401) Reason: Unauthorized HTTP response headers: HTTPHeaderDict({'Server': 'Server', 'Date': 'Thu, 01 Jul 2021 09:29:50 GMT', 'Content-Type': 'application/json', 'Content-Length': '320', 'Connection': 'keep-alive', 'x-amz-rid': '6M7ZZBARR7KPJ8YEV5JS', 'x-amzn-RequestId': 'd920d9d8-955c-4901-8ec5-e9402df5493e', 'Vary': 'Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent', 'Permissions-Policy': 'interest-cohort=()'}) HTTP response body: {"__type":"com.amazon.paapi5#InvalidSignatureException","Errors":[{"Code":"InvalidSignature","Message":"The request has not been correctly signed. If you are using an AWS SDK, requests are signed for you automatically; otherwise, go to https://webservices.amazon.it/paapi5/documentation/sending-request.html#signing."}]}

how handle the InvalidSignatureException?

"class Class" is confusing when debugging

In amazon/parse.py, the class named "Class" is confusing - my suggestion would be to create specifically named class instances for each entity. Something like the following:

class AmazonBase:
    pass

class AmazonProduct(AmazonBase):
    pass

class AmazonProductInfo(AmazonBase):
    pass

class AmazonContributor(AmazonBase):
    pass

etc.

Then, when instantiating (for instance) product.info, we would instantiate product.info = AmazonProductInfo(). A contributor would be contributor = AmazonContributor().

When debugging, rather than seeing an error like TypeError: Object of type Class is not JSON serializable, which is confusing and doesn't let the user know that the error is part of the Amazon Product API logic, it would be more specific, for instance TypeError: Object of type AmazonContributor is not JSON serializable.

Let me know your thoughts @sergioteula ? Happy to write a PR if it's helpful.

Raise Exceptions

Your library handle all exceptions internally making it impossible for end user to know if a key is revoked, or he is calling api too fast or what's going wrong.

Raise the actual exception and let end users handle it.

For this reason alone I had to migrated to https://github.com/alefiori82/amazon-paapi5 which handles exceptions in a better way.

Project improvements

  • Add branch naming conventions
  • Add pull requests guidelines
  • Create develop branch
  • Add PyPi upload on release
  • Add code format to README

[Nice to have] Include a test suite that includes a mock Amazon object with all potential values

It would be really nice to have a test suite for the repo. In particular, including something like mocks.py that includes a mock product returned by this repo would help users to unit test our applications.

I may have time to start on this - I focus only on books but could be a good start to creating a test suite for this repo.

Would also be nice to show code coverage and test suite status on CI.

TooManyRequests Error

I'm getting the below error:

HTTP response body: {"__type":"com.amazon.paapi5#TooManyRequestsException","Errors":[{"Code":"TooManyRequests","Message":"The request was denied due to request throttling. Please verify the number of requests made per second to the Amazon Product Advertising API."}]}

I have tried the demo code and have played around with the throttling but still no luck... Any ideas?

from amazon.paapi import AmazonAPI
amazon = AmazonAPI("x", "x", "x", "US", throttling=0.5)
product = amazon.get_product('B01N5IB20Q')
print(product.title)

get_products returns multiple products unordered

Discussed in #68

Originally posted by aashishsaini75 June 9, 2021
@sergioteula I think something is not good with the get_products function, I am passing a list of asins in function to get the price value and also getting the response but the response is not returned in a order of list i am passing like the product[0].prices.price.value response should be the result of first asin of a list but it returned the value randomly of any of the asins.
See the attached images to get better understanding
image

ResponseError using Search_Products

Context
I am attempting to use search_products() to find all items for a given keyword. So I am inputting one keyword and returning the metadata of the items returned in the search.

However, I am running into a No Response error [AmazonException: ResponseError: NoResults: No results found for your request.]The problem occurs when the input keyword’s total_results_count is less than then item_count.

For example, the keyword, ‘norwegian operation’.

My script is calling search_products like this → products=amazon.search_products(item_count=100, keywords='norwegian operation', search_index = "KindleStore")

And getting the response → [ AmazonException: ResponseError: NoResults: No results found for your request.] From line 292.

Environment
I am using a macOS Catalina Version 10.15.3 and Python 3.7.

Steps to Reproduce Errors
products=amazon.search_products(item_count=100, keywords='norwegian operation', search_index = "KindleStore")

Expected Behavior
This issue arises because the keyword ‘norwegian operation’ only has 40 total_result_count. If you change the item_count to 40 or less it does not raise this error. I would like to get the resulting items regardless of the total results. The paaapi.py allows for a response if there is no results, but not if the total_result_count is less than the item_count.

getBrowseNodes function

Hey,

Thanks for creating this great module. We know you may still create the new features. But would you mind to share any plan or schedule to build getBrowseNodes function in this module in future? Since we need this function for our project.

Thanks again!

ApiException: (500) Reason: Internal Server Error

Hello there
Today i'm receiving a very strange error.

ApiException: (500) Reason: Internal Server Error HTTP response headers: HTTPHeaderDict({'Server': 'Server', 'Date': 'Tue, 12 Jan 2021 17:53:45 GMT', 'Content-Type': 'application/json', 'Content-Length': '168', 'Connection': 'keep-alive', 'x-amz-rid': '565JTC4ZNV1CWMKZYWAH', 'x-amzn-RequestId': 'f0176e0a-fa38-4e60-b179-eddb1aa62d42', 'Vary': 'Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent'}) HTTP response body: {"__type":"com.amazon.coral.service#InternalFailure","message":"The request processing has failed due to some unknown error, exception or failure. Please retry again."}

I don't know the reason why, it doesn't work on webapp and local running. On scratchpad my key works.

sales rank

Is sales rank still available through the API? If so, it'd be great to have access to that.

URL for Amazon Warehouse

Hi, i'm really appreciating your work! I have one thing to ask. I can use Amazon Warehouse link to get the product and this is really cool. I found the way to get the lowest price in the warehouse and that's fantastic. The only thing i can't find is the URL with tag for the Amazon Warehouse's page of the product.
There is 1 URL and goes always on the page of the standard Amazon.
I hope you can understand what i'm saying and help me 🤣
Thank you again

Exception on product that is not available at the moment

Hello,

when I start a product search with ASIN B084FCWBLZ I get an exception "AttributeError: 'NoneType' object has no attribute 'small' in line 652". And no product is returning. The item is listed on amazon but is actually not available. I use DE as region.

prices should also return currency

Hi,
Prices seems to return pvp and price, but not currency (but it is returned in offers).

For consistency, there should be a product.prices.currency

Thanks

ASIN of a product that caused AsinNotFoundException

Hi, I'm trying to get a few items in a single request and got an AsinNotFoundException error. How do I know which one ASIN from the list caused the error?

items = amazon.get_items(['XXXX', 'YYYYY'])

Thanks!

ASIN isnt always returned or accepted

ASINs which exist sometimes return the product without an asin value in the response object, and are sometimes only accepted when they are all uppercase. maybe the asin can be converted to uppercase and inserted into the object asin if it doesnt exist in the response?

Too many request

Hi, I am using your code, and it is fantastic.

But I am getting the error "Too many requests", I am calling the api with a time.sleep(2) to wait one or two seconds before call again the api. I don't know if it is relative to the api or other problem.

I am not using the api credentials y other programs.

Thanks

Spell Mistake lenght

dir(a.product.dimensions) duce_ex__', 'repr', 'setattr', 'sizeof', 'str', '__subcl
['class', 'delattr', 'dict', 'dir', 'doc', 'eq', 'format',
'ge', 'getattribute', 'gt', 'hash', 'init', 'init_subclass', 'le', 'lt', 'module', 'ne', 'new', 'reduce', 'reduce_ex', 'repr', 'setattr', 'sizeof', 'str', 'subclasshook', 'weakref', 'height', 'lenght', 'width']

a.product.dimensions.length
Traceback (most recent call last):
File "", line 1, in
AttributeError: 'Class' object has no attribute 'length'

a.product.dimensions.lenght
<amazon.parse.Class object at 0x03319C70>

Is this advertising api?

I don't see the functions for creating ad campaigns, groups etc. So is this just the product api or advertising as well?

Nonexistent discount retrieved

Hello!

A lot of times when I use the min_discount parameter on the "search_products" method I experience two issues:

  • The items retrieved have a lower discount. This can be solved by filtering items manually later
  • The discount in the "product.prices.price.savings.percentage" field is not present in Amazon. When I visit the product's page, there's no discount or there's a much lower one.

I've tried to access only the IT marketplace.

Here's a test case code snippet:

    min_discount = 70

    products = client.search_products(keywords="pc,usb", min_discount=min_discount, item_count=10)

    for product in products:
        discount = product.prices.price.savings.percentage

        if not discount or discount < min_discount:
            continue

        print("[{}%] {} {}".format(discount, product.title, product.url))
        print(product.info.product_group)
        print("---")

Ignore multiple links in get_product and return only the first one

In get_product function there is a split(",") method that split passed string and if the returned list's lenght is greater than one, it raises an error.

I think it could be better that with get_product function you get only the product of first asin (or url), ignoring the rest.

It could be useful also when you have urls like https://www.amazon.it/canzone-Achille-Madeline-Miller-ebook/dp/B07LGBM18M?__mk_it_IT=%C3%85M%C3%85%C5%BD%C3%95%C3%91&crid=R96BEWN0UBFE&dchild=1&keywords=la+canzone+di+achille&qid=1615931295&sprefix=la+canzone,aps,190&sr=8-2&linkCode=sl1&tag=flow074-21&linkId=6f4cfda5b4222977473aa183b503e2db&language=it_IT&ref_=as_li_ss_tl where there are two commas inside.

What do you think?

Originally posted by @barbax7 in #57

'NoneType' object is not subscriptable

I get the following error if the product is not available anymore.

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-129-1b28dcb36038> in <module>
----> 1 product = amazon.get_product('B071YR89XJ')

~/dev/project/lib/python3.6/site-packages/amazon/paapi.py in get_product(self, product_id, condition, merchant, async_req)
    166                                                     'get_products for multiple requests')
    167         return self.get_products(product_id, condition=condition, merchant=merchant,
--> 168                                  async_req=async_req)[0]
    169 
    170     def search_products(self, item_count=10, item_page=1, items_per_page=10, keywords=None,

TypeError: 'NoneType' object is not subscriptable

eg. page: https://www.amazon.com/natiga-ng-0141-Cherrys-Enamel-Brooch/dp/B071YR89XJ

even the amazon page shows 404 but product used to be available.

in this case error handling could be improved.

Thanks

TypeError: 'NoneType' object is not callable raised by wrapped API

Thank you for building this repo, and for being so responsive! Also thanks for making the license change.

I'm getting this exception in my code after a 400 response from Amazon:

Exception ignored in: <function ApiClient.__del__ at 0x10e10e268>
Traceback (most recent call last):
  File "/Users/myuser/.virtualenvs/mysite/lib/python3.7/site-packages/paapi5_python_sdk/api_client.py", line 104, in __del__
  File "/usr/local/var/pyenv/versions/3.7.0/lib/python3.7/multiprocessing/pool.py", line 539, in close
TypeError: 'NoneType' object is not callable

I'm still investigating and will make a PR if I find any issues I can fix, but leaving this here for now in case other users encounter the same problem.

Python script execution may not finish

Thank you for useful wrapper module!
I was just looking for such software.
It's very helpful!

But I found a symptomatology that the script execution cannot be finished...

I ran the following code for my test on both Mac and Windows.
main.py:

# -*- coding: utf-8 -*-
from amazon_paapi import AmazonApi
 
KEY     = "XXXX"
SECRET  = "XXXX"
TAG     = "XXXX"
COUNTRY = "JP"

if __name__ == "__main__":
    amazon = AmazonApi(KEY, SECRET, TAG, COUNTRY)
    items = amazon.get_items(['B01N5IB20Q', 'B01F9G43WU'])
    for item in items:
        print(item.images.primary.large.url) # Primary image url
        print(item.offers.listings[0].price.amount) # Current price

On mac, the execution immediately after launching the terminal didn't finish successfully.
(It didn't finish until I used Control-C)
(The second and subsequent executions finished successfully)
Terminal on Mac:

testuser@Mac test % python main.py
https://m.media-amazon.com/images/I/41cKE7Id6AL._SL500_.jpg
4490.0
https://m.media-amazon.com/images/I/41s20oziIJL._SL500_.jpg
4424.0
(sometimes freezes here )

On the other hand, the execution on Windows always couldn't finish successfully.
It always didn't finish until I used Control-C.

My environment:

  • Python: 3.8.8 on both OS
  • python-amazon-paapi: 4.1.1
  • macOS: Catelina 10.15.7
  • Windows OS: Windows 7

Do you know the cause and workaround?

Getting Reviews (feature request)

This wrapper is awesome!
Please add the ability to get the star rating of a product (4/5 for example) and customer reviews at the bottom of product pages.

Proxy

I need to send requests to webservices.amazon.it through a proxy server. How can I set it?

Not an issue but few questions

Thank you for picking up the pa api5 library develoment.
I have few queries as below:

1. Why are you normalizing links by appending .AC.?
The image url shows highest quality available with if you remove all link functions xx part and keep .jpg simply. This way links are little small and unified with other library.

2. Can we setup a chat on Telegram, gitter or slack instead so users can us that for non-issue type queries for faster development?
paapi5 library is much needed right now and a chat will fasten the development, discussion and suggestion.

Get Browsenodes Error

amazon.get_browsenodes(browse_nodes=['3375301']) gives an error after adding import pprint, six to the parse.py file:

NameError Traceback (most recent call last)
in
1 bnData = amazon.get_browsenodes(browse_nodes=['3375301'])
2
----> 3 print(bnData)

~/opt/miniconda3/lib/python3.7/site-packages/amazon/parse.py in repr(self)
59
60 def repr(self):
---> 61 return self.to_str()
62
63 def eq(self, other):

~/opt/miniconda3/lib/python3.7/site-packages/amazon/parse.py in to_str(self)
56
57 def to_str(self):
---> 58 return pprint.pformat(self.to_dict())
59
60 def repr(self):

~/opt/miniconda3/lib/python3.7/site-packages/amazon/parse.py in to_dict(self)
49 else:
50 result[attr] = value
---> 51 if issubclass(BrowseNode, dict):
52 for key, value in self.items():
53 result[key] = value

NameError: name 'BrowseNode' is not defined

Please let me know how to correct. Thanks for this great module.

ModuleNotFoundError: No module named 'amazon'

That's my simple code:

KEY = ""
SECRET = ""
TAG = ""
COUNTRY = "UK"
from amazon.paapi import AmazonAPI
amazon = AmazonAPI(KEY, SECRET, TAG, COUNTRY)
product = amazon.get_product('B01N5IB20Q')
print(product.title)

but I get this error
from amazon.paapi import AmazonAPI
ModuleNotFoundError: No module named 'amazon'

Please can someone help me?

Remove while loop from search_products

I think that the while loop in search_products is causing more issues than it solves. If someone needs to use the pagination they can use the item_count and items_per_page parameters built into the SDK.

As currently implemented the while loop means that any time a user searches for a product and the search returns fewer than item_count results they're actually making two calls to the API, not one call.

So, if the user searches for a very specific title, and the API returns one result, but we have item_count set by default to ten items, the wrapper makes a second (unnecessary) call to Amazon.

Invalid Signature?

amazon.exception.AmazonException: ApiException: (401)
Reason: Unauthorized

HTTP response body: {"__type":"com.amazon.paapi5#InvalidSignatureException","Errors":[{"Code":"InvalidSignature","Message":"The request has not been correctly signed. If you are using an AWS SDK, requests are signed for you automatically; otherwise, go to https://webservices.amazon.com/paapi5/documentation/sending-request.html#signing."}]}

Any idea why this is happening?

InvalidSignature Exception when making requests from Google App Engine

I'm trying to do a request which is working just fine from my local console. But once I try to make the same request from App Engine, I get this error:

ApiException: (401) Reason: Unauthorized HTTP response headers: HTTPHeaderDict({'x-amzn-RequestId': '9c9d9a24-c503-47e7-a912-ca0c79640ec2', 'Content-Length': '321', 'Vary': 'Content-Type,Accept-Encoding,X-Amzn-CDN-Cache,X-Amzn-AX-Treatment,User-Agent', 'Server': 'Server', 'x-amz-rid': 'M2SS3YJWJG78096WQ7R5', 'Connection': 'keep-alive', 'Date': 'Mon, 19 Oct 2020 22:59:44 GMT', 'Content-Type': 'application/json'}) HTTP response body: {"__type":"com.amazon.paapi5#InvalidSignatureException","Errors":[{"Code":"InvalidSignature","Message":"The request has not been correctly signed. If you are using an AWS SDK, requests are signed for you automatically; otherwise, go to https://webservices.amazon.com/paapi5/documentation/sending-request.html#signing."}]}

Add compatibility with product URL

I will be adding compatibility with product URL, not only product ASIN. This way you will be able to get product information by passing the URL directly.

Invalid Signature Exception??

amazon.exception.AmazonException: ApiException: (401)
Reason: Unauthorized

HTTP response body: {"__type":"com.amazon.paapi5#InvalidSignatureException","Errors":[{"Code":"InvalidSignature","Message":"The request has not been correctly signed. If you are using an AWS SDK, requests are signed for you automatically; otherwise, go to https://webservices.amazon.com/paapi5/documentation/sending-request.html#signing."}]}

Any idea why this is happening?

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.