Skip to main content

A simple Python wrapper for the Amazon.com Product Advertising API

Project description

A simple Python wrapper for the Amazon.com Product Advertising API. [![Build Status](https://secure.travis-ci.org/yoavaviram/python-amazon-simple-product-api.png?branch=master)](http://travis-ci.org/yoavaviram/python-amazon-simple-product-api)

Features

  • An object oriented interface to Amazon products

  • Supports both item search and item lookup

  • Compatible with Google App Engine

Dependencies

Before you get started, make sure you have:

  • Installed [Bottlenose](https://github.com/dlo/bottlenose) (pip install bottlenose)

  • Installed lxml (pip install lxml)

  • An Amazon Product Advertising account

  • An AWS account

Usage

Lookup:

>>> from amazon.api import AmazonAPI
>>> amazon = AmazonAPI(AMAZON_ACCESS_KEY, AMAZON_SECRET_KEY, AMAZON_ASSOC_TAG)
>>> product = amazon.lookup(ItemId="B0051QVF7A")
>>> product.title
'Kindle, Wi-Fi, 6" E Ink Display - for international shipment'
>>> product.price_and_currency
(109.0, 'USD')
>>> product.ean
'0814916014354'
>>> product.large_image_url
'http://ecx.images-amazon.com/images/I/411H%2B731ZzL.jpg'
>>> product.get_attribute('Publisher')
'Amazon Digital Services, Inc'
>>> product.get_attributes(['ItemDimensions.Width', 'ItemDimensions.Height'])
{'ItemDimensions.Width': '450', 'ItemDimensions.Height': '34'}

The API wrapper supports many other product attributes as well.

Search:

>>> 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)
0. 'Kindle, Wi-Fi, 6" E Ink Display - includes Special Offers & Sponsored Screensavers'
1. 'Kindle Fire, Full Color 7" Multi-touch Display, Wi-Fi'
2. 'Kindle US Power Adapter (Not included with Kindle or Kindle Touch)'
3. 'Kindle Touch, Wi-Fi, 6" E Ink Display - includes Special Offers & Sponsored Screensavers'
4. 'Kindle Keyboard 3G, Free 3G + Wi-Fi, 6" E Ink Display - includes Special Offers & Sponsored Screensavers'
5. 'Kindle Touch 3G, Free 3G + Wi-Fi, 6" E Ink Display - includes Special Offers & Sponsored Screensavers'
...
49. 'Kindle Wireless Reading Device (6" Display, U.S. Wireless)'

The search method returns an iterable that will iterate through all products, on all pages available. Additional pages are retrieved automatically as needed. Keep in mind that Amazon limits the number of pages it makes available.

For more information about these calls, please consult the [Product Advertising API Developer Guide](http://docs.amazonwebservices.com/AWSECommerceService/latest/DG/index.html).

There is also a convenience method to search and return a list of the first N results:

>>> from amazon.api import AmazonAPI
>>> amazon = AmazonAPI(AMAZON_ACCESS_KEY, AMAZON_SECRET_KEY, AMAZON_ASSOC_TAG)
>>> products = amazon.search_n(1, Keywords='kindle', SearchIndex='All')
>>> len(products)
1
>>> products[0].title
'Kindle, Wi-Fi, 6" E Ink Display - includes Special Offers & Sponsored Screensavers'

Tests

To run the test suite please follow these steps:

  • Make sure [Nose](http://readthedocs.org/docs/nose/en/latest/) is installed: (pip install nose)

  • Create a local file named: test_settings.py with the following variables set to the relevant values: AMAZON_ACCESS_KEY, AMAZON_SECRET_KEY, AMAZON_ASSOC_TAG

  • Run nosetests

License

Copyright © 2012 Yoav Aviram

See LICENSE for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

File details

Details for the file python-amazon-simple-product-api-1.0.6.tar.gz.

File metadata

File hashes

Hashes for python-amazon-simple-product-api-1.0.6.tar.gz
Algorithm Hash digest
SHA256 ad6c3168fbaca3c2adcee03797c4cf8c787f55d16a02bbd2f6319994190a2713
MD5 78873240ab9579e43f0b05a51e576a5b
BLAKE2b-256 a5db70d06b19fa2fab7b9748d83ae5ee04e605cc692404feaaa860a40df720f1

See more details on using hashes here.

File details

Details for the file python_amazon_simple_product_api-1.0.6-py2.7.egg.

File metadata

File hashes

Hashes for python_amazon_simple_product_api-1.0.6-py2.7.egg
Algorithm Hash digest
SHA256 bd5ff74f1104a7c5afe77e39efa8d6b6993352e4e9c2a4c65b719010784670f2
MD5 b61ba39b7c85ce42e92616da872fe766
BLAKE2b-256 2e7b89509d27ca9f9213cabdf02ccc8fd9e008bfbc974ff993e16335ba18df24

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page