An easy way to hit the Amazon Product API in Python

You can hit the API yourself, but the documentation is hard to read, I haven't written what parameters are needed in the request after all, and I have to add my own hashed Sigunature to the URL. It's a hassle without it, so use a convenient library.

python-amazon-simple-product-api

It's super convenient. You can find out the installation etc. immediately by reading the README.

When I actually run it, it looks like this. If you do not specify the region, you may be searching overseas stores, or you will not be able to find the product, so be sure to remember region =" JP ".

In [9]: amazon = AmazonAPI(ACCESS_KEY, SECRET_KEY, ASSOCIATE_ID, region="JP")
In [10]: product = amazon.lookup(ItemId='B00E7N623K')
In [11]: product.__dict__
Out[11]:
{'api': <amazon.api.AmazonAPI at 0x1037e9cf8>,
 'aws_associate_tag': 'Associate ID',
 'parent': None,
 'parsed_response': <Element {http://webservices.amazon.com/AWSECommerceService/2013-08-01}Item at 0x1035b9e08>,
 'region': 'JP'}

In [12]: product.parsed_response
Out[12]: <Element {http://webservices.amazon.com/AWSECommerceService/2013-08-01}Item at 0x1035b9e08>

In [13]: product.parsed_response.ItemAttributes
Out[13]: <Element {http://webservices.amazon.com/AWSECommerceService/2013-08-01}ItemAttributes at 0x10382e508>

In the contents of the library, I feel that lxml is parsing the xml response. In fact, even in the above execution example, the Element instance of lxml is nested and included.

I've read the official API documentation for a long time, but obviously this is easier.

Recommended Posts

An easy way to hit the Amazon Product API in Python
Hit the Sesami API in Python
Hit the web API in Python
Easy way to use Wikipedia in Python
Hit the New Relic API in Python to get the server status
An easy way to view the time taken in Python and a smarter way to improve it
Hit the Firebase Dynamic Links API in Python
An easy way to call Java from Python
Hit Mastodon's API in Python
Easy way to check the source of Python modules
To automatically send an email with an attachment using the Gmail API in Python
An easy way to pad the number with zeros depending on the number of digits [Python]
[Python] An easy way to visualize energy data interactively [plotly.express]
An introduction to the modern socket API to learn in C
Getting the arXiv API in Python
Easy way to customize Python import
[Python] Hit the Google Translation API
In the python command python points to python3.8
Hit the Etherpad-lite API with Python
Access the Twitter API in Python
An alternative to `pause` in Python
[Python Tutorial] An Easy Introduction to Python
How to know the internal structure of an object in Python
Easy way to round off to the nearest whole number with python3
An easy way to re-execute a previously executed command in ipython
Regularly upload files to Google Drive using the Google Drive API in Python
Python beginners hit the unofficial API of Google Play Music to play music
How to display bytes in the same way in Java and Python
Try using the Wunderlist API in Python
Try using the Kraken API in Python
Tweet using the Twitter API in Python
Try hitting the YouTube API in Python
[Python] I tried to summarize the set type (set) in an easy-to-understand manner.
Hit the Rakuten Ranking API to save the ranking of any category in CSV
Sample code to get the Twitter API oauth_token and oauth_token_secret in Python 2.7
What is the fastest way to create a reverse dictionary in python?
An example of the answer to the reference question of the study session. In python.
How to use the C library in Python
The fastest way for beginners to master Python
Easy way to use Python 2.7 on Cent OS 6
The easiest way to synthesize speech with python
Try using the BitFlyer Ligntning API in Python
To dynamically replace the next method in python
Install the python package in an offline environment
Draw graphs in Julia ... Leave the graphs to Python
A clever way to time processing in Python
Tips for hitting the ATND API in Python
Excel X Python The fastest way to work
The easiest way to use OpenCV with python
The trick to write flatten concisely in python
Introduction to Python with Atom (on the way)
How to get the files in the [Python] folder
Issue the Amazon CloudFront Signed URL in Python
An article summarizing the pitfalls addicted to python
I want to display the progress in Python!
Try using the DropBox Core API in Python
[Python] I want to know the variables in the function when an error occurs!
Searching for an efficient way to write a Dockerfile in Python with poetry
Continue to retrieve tweets containing specific keywords using the Streaming API in Python
Create a filter to get an Access Token in the Graph API (Flask)
I tried to explain how to get the article content with MediaWiki API in an easy-to-understand manner with examples (Python 3)