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

Overview

Amazon Simple Product API

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

Build Status Documentation Status Coverage Status PyPI version PyPI - License PyPI - Downloads PyPI - Python Version Code Shelter

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 (pip install bottlenose)
  • Installed lxml (pip install lxml)
  • Installed dateutil (pip install python-dateutil)
  • An Amazon Product Advertising account
  • An AWS account

Installation

 pip install python-amazon-simple-product-api

Usage

Lookup:

 >>> from amazon.api import AmazonAPI
 >>> amazon = AmazonAPI(AMAZON_ACCESS_KEY, AMAZON_SECRET_KEY, AMAZON_ASSOC_TAG)
 >>> product = amazon.lookup(ItemId='B00EOE0WKQ')
 >>> product.title
 'Amazon Fire Phone, 32GB (AT&T)'
 >>> product.price_and_currency
 (199.0, 'USD')
 >>> product.ean
 '0848719035209'
 >>> product.large_image_url
 'http://ecx.images-amazon.com/images/I/51BrZzpkWrL.jpg'
 >>> product.get_attribute('Publisher')
 'Amazon'
 >>> product.get_attributes(['ItemDimensions.Width', 'ItemDimensions.Height'])
 {'ItemDimensions.Width': '262', 'ItemDimensions.Height': '35'}

(the API wrapper also supports many other product attributes)

Lookup on amazon.de instead of amazon.com by setting the region:

 >>> from amazon.api import AmazonAPI
 >>> import bottlenose.api
 >>> region_options = bottlenose.api.SERVICE_DOMAINS.keys()
 >>> region_options
 ['US', 'FR', 'CN', 'UK', 'IN', 'CA', 'DE', 'JP', 'IT', 'ES']
 >>> amazon_de = AmazonAPI(AMAZON_ACCESS_KEY, AMAZON_SECRET_KEY, AMAZON_ASSOC_TAG, region="DE")
 >>> product = amazon_de.lookup(ItemId='B0051QVF7A')
 >>> product.title
 u'Kindle, WLAN, 15 cm (6 Zoll) E Ink Display, deutsches Men\xfc'
 >>> product.price_and_currency
 (99.0, 'EUR')

Bulk lookup requests are also supported:

 >>> from amazon.api import AmazonAPI
 >>> amazon = AmazonAPI(AMAZON_ACCESS_KEY, AMAZON_SECRET_KEY, AMAZON_ASSOC_TAG)
 >>> products = amazon.lookup(ItemId='B00KC6I06S,B005DOK8NW,B00TSUGXKE')
 >>> len(products)
 5
 >>> products[0].asin
 'B0051QVESA'

If you'd rather get an empty list intead of exceptions use lookup_bulk() instead.

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.

Valid values of SearchIndex are: 'All','Apparel','Appliances','ArtsAndCrafts','Automotive', 'Baby','Beauty','Blended','Books','Classical','Collectibles','DVD','DigitalMusic','Electronics', 'GiftCards','GourmetFood','Grocery','HealthPersonalCare','HomeGarden','Industrial','Jewelry', 'KindleStore','Kitchen','LawnAndGarden','Marketplace','MP3Downloads','Magazines','Miscellaneous', 'Music','MusicTracks','MusicalInstruments','MobileApps','OfficeProducts','OutdoorLiving','PCHardware', 'PetSupplies','Photo','Shoes','Software','SportingGoods','Tools','Toys','UnboxVideo','VHS','Video', 'VideoGames','Watches','Wireless','WirelessAccessories'

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'

Similarity Lookup:

 >>> from amazon.api import AmazonAPI
 >>> amazon = AmazonAPI(AMAZON_ACCESS_KEY, AMAZON_SECRET_KEY, AMAZON_ASSOC_TAG)
 >>> products = amazon.similarity_lookup(ItemId='B0051QVESA,B005DOK8NW')
 >>> len(products)
 4

Browse Node Lookup:

 >>> from amazon.api import AmazonAPI
 >>> amazon = AmazonAPI(AMAZON_ACCESS_KEY, AMAZON_SECRET_KEY, AMAZON_ASSOC_TAG)
 >>> bn = amazon.browse_node_lookup(BrowseNodeId=2642129011)
 >>> bn.name
 'eBook Readers'

Create and manipulate Carts:

 >>> from amazon.api import AmazonAPI
 >>> amazon = AmazonAPI(AMAZON_ACCESS_KEY, AMAZON_SECRET_KEY, AMAZON_ASSOC_TAG)     
 >>> product = amazon.lookup(ItemId="B0016J8AOC")
 >>> item = {'offer_id': product.offer_id, 'quantity': 1}
 >>> cart = amazon.cart_create(item)
 >>> fetched_cart = amazon.cart_get(cart.cart_id, cart.hmac)
 >>> another_product = amazon.lookup(ItemId='0312098286')
 >>> another_item = {'offer_id': another_product.offer_id, 'quantity': 1}
 >>> another_cart = amazon.cart_add(another_item, cart.cart_id, cart.hmac)     
 >>> cart_item_id = None
 >>> for item in cart:
 >>>     cart_item_id = item.cart_item_id
 >>> modify_item = {'cart_item_id': cart_item_id, 'quantity': 3}
 >>> modified_cart = amazon.cart_modify(item, cart.cart_id, cart.hmac)     
 >>> cleared_cart = amazon.cart_clear(cart.cart_id, cart.hmac)

For the 'Books' SearchIndex a Power Search option is avaialble:

 >>> products = amazon.search(Power="subject:history and (spain or mexico) and not military and language:spanish",SearchIndex='Books')

For more information about these calls, please consult the Product Advertising API Developer Guide.

Tests

To run the test suite please follow these steps:

  • Make sure Nose 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

Pull Requests

  • All code should be unit tested
  • All tests must pass
  • Source code should be PEP8 complient
  • Coverage shouldn't decrease
  • All Pull Requests should be rebased against master before submitting the PR

This project is looking for core contributors. Please message me.

License

Copyright © 2012 Yoav Aviram

See LICENSE for details.

Owner
Yoav Aviram
Business Innovator, Entrepreneur, Investor, Independent Academic, Activist
Yoav Aviram
📷 Instagram Bot - Tool for automated Instagram interactions

InstaPy Tooling that automates your social media interactions to “farm” Likes, Comments, and Followers on Instagram Implemented in Python using the Se

Tim Großmann 13.5k Dec 01, 2021
Diablo II Resurrected Diablo Clone Running Room Mgr

d2rdc Diablo II Resurrected Diablo Clone Running Room Mgr Install Dependencies pip install fastapi pip install uvicorn Running uvicorn init:app INFO:

1 Dec 03, 2021
A Telegram Most Powerful Media Info Bot.

Media Info Bot Support 🚑 Demo For The Bot -Test Our Bot By Clicking The Button Below Deploy To Heroku 🗳 Press the Deploy Button to Get Your Own Bot.

Anonymous 5 May 16, 2022
A simple tool that allows you to change your default AWS CLI profile.

Select AWS Profile Select AWS Profile (slapr) is a simple tool that lets you select which AWS Profile you want to use and sets it as the default AWS p

Antoni Yanev 2 Nov 09, 2022
This is a okay that is okay that means none is okay

Owner: Masterolic 🇮🇳 CatUB A Powerful, Smart And Simple Userbot In Telethon. Credits This is A Remix Bot Of Many UserBot. DARKCOBRA FridayUserBot Ja

Masterolic 1 Nov 28, 2021
A Telegram Bot written in Python for mirroring files on the Internet to Google Drive

No support is going to be provided of any kind, only maintaining this for vps user on request. This is a Telegram Bot written in Python for mirroring

0 Dec 26, 2021
Instagram-follower-bot - An Instagram follower bot written in Python

Instagram Follower Bot An Instagram follower bot written in Python. The bot follows the follower of which account you want. e.g. (You want to follow @

Aytaç Kaşoğlu 1 Dec 31, 2021
An alternative launcher for Lunar Client which is aimed at portability and functionality.

Portaluna An alternative launcher for Lunar Client which is aimed at portability and functionality. Features Portable. Lightweight. Functional. Note:

4 Mar 05, 2022
Sakamata-alpha-pycord - Sakamata bot alpha with pycord

sakamatabot このリポジトリは? ホロライブ所属VTuber沙花叉クロヱさんの非公式ファンDiscordサーバー「クロヱ水族館」の運営/管理補助を行う

sushichaaaan 1 May 04, 2022
A Really Simple and Advanced Google Colab NoteBook to Setup and start using Rclone on Google Colab easily.

Rclone on Google Colab (Advanced!) 🔥 1.Setup and Start using Rclone on Google Colab and Create/Edit/View and delete your Rclone config file and keep

Dr.Caduceus 14 May 24, 2022
A discord bot that autobans blacklisted users by ID and Names

AutoBan A discord bot that autobans blacklisted users by ID and Names Getting Started Dependencies disnake @ git+https://github.com/DisnakeDev/disnake

Jason Martin 0 Oct 02, 2022
Twitch Linux Typer

Twitch Linux Typer The most cursed Twitch chat bot Listens to twitch chat, and then types it handles hotkeys and button presses via the ^ char, eg ctr

Robin Universe 4 Jun 27, 2022
ToqueIO Nuke tools - A collection of tools designed to assist in enhancing your workflows within nuke

ToqueIO Nuke tools - A collection of tools designed to assist in enhancing your workflows within nuke

4 Feb 19, 2022
Find rare users in discord servers

BadgeScraper Find rare users in discord servers How to use Replace the guild_id, server_id and token by the values you wanna use If you never used dis

20 Dec 09, 2022
Find people to play tennis with.

40Love 40Love is a full-stack web application that helps tennis players find hits at public tennis courts. Players can select public courts on the map

Tanner Schmutte 27 Jun 08, 2022
Telegram vc - A bot that can play music on telegram group's voice call

Telegram Voice Chat Bot A bot that can play music on telegram group's voice call

1 Jan 02, 2022
This is a free python bot program that crosses you to farm with auto click in space crypto NFT game, having fun :) Creator: Marlon Zanardi

🚀 Space Crypto auto click bot ready-to-use 🚀 This is a free python bot program that crosses you to farm with auto click in space crypto NFT game, ha

170 Dec 20, 2022
A simple language translator with python and google translate api

Language translator with python A simple language translator with python and google translate api Install pip and python 3.9. All the required depende

0 Nov 11, 2021
A bot written in Python to automate attending classes on MyClass (Codetantra).

codetantrabot This is python program to attend class on myclass(codetantra) Prerequisites You should have Python3 and Pip installed on your system Run

Aniket Kumar 1 Feb 08, 2022
An Advanced Python Playing Card Module that makes creating playing card games simple and easy!

playingcards.py An Advanced Python Playing Card Module that makes creating playing card games simple and easy! Features Easy to Understand Class Objec

Blake Potvin 5 Aug 30, 2022