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
This is a open source discord bot project

pythonDiscordBot This is a open source discord bot project #based on the MAX A video: https://www.youtube.com/watch?v=jHZlvRr9KxM Prerequisites Python

Edson Holanda Teixeira Junior 3 Oct 11, 2021
A discord bot thet lets you play Space invaders.

space_Invaders A discord bot thet lets you play Space invaders. It is my first discord bot... so please give any suggestions to improve it :] Commands

2 Dec 30, 2021
Export Statistics for a Telegram Group Chat

Telegram Statistics Export Statistics for a Telegram Group Chat How to Run First, in main repo directory, run the following code to add src to your PY

Ali Hejazizo 22 Dec 05, 2022
Cloud-optimized, single-file archive format for pyramids of map tiles

PMTiles PMTiles is a single-file archive format for tiled data. A PMTiles archive can be hosted on a commodity storage platform such as S3, and enable

Protomaps 325 Jan 04, 2023
Simple Translator in Python

Simple Translator in Python Project Description: In this project, we'll be making a very simple translator in Python using some libraries. Requirement

Hassan Shahzad 3 Jan 23, 2022
Telegram bot that let's you flip a coin in a dialog

coin_flip Telegram bot that let's you flip a coin in a dialog Report issue · Request feature About Software development tool that lets you finally dec

Ivan Akostelov 2 Dec 12, 2021
A Discord bot for osu!

This is the mostly-complete repo for the owo Discord osu! bot which you can invite here. As you look through this repo, please keep in mind that all o

Stevy 43 Dec 28, 2022
A part of HyRiver software stack for accessing hydrology data through web services

Package Description Status PyNHD Navigate and subset NHDPlus (MR and HR) using web services Py3DEP Access topographic data through National Map's 3DEP

Taher Chegini 51 Dec 10, 2022
Azure Neural Speech Service TTS

Written in Python using the Azure Speech SDK. App.py provides an easy way to create an Text-To-Speech request to Azure Speech and download the wav file.

Rodney 1 Oct 11, 2021
A simple python script for rclone. Use multiple Google Service Accounts and cycle through them.

About GSAclone GSAclone is a simple python script for rclone, written with the purpose of using multiple Google service accounts on Google Drive and "

Shiro39 6 Feb 25, 2022
A Git Alert Bot - Github Integration for Pyrogram & Telethon

Yet Another GitAlertBot Inspired From @Pokurt's GitGram Run Bot: Local Host Git Clone Repo : For Telethon Version : git clone https://github.com/DevsE

DevsExpo 23 Oct 21, 2022
Moderation By Pokemon Bot (Discord)

Moderation Bot By Pokémon Bot (Discord) Official Moderation Bot for Pokemon Bot functional and based in the Discord Server, the bot is written in Pyth

Aakash Manoj Agrawal 6 Jan 04, 2022
📢 Video Chat Stream Telegram Bot. Can ⏳ Stream Live Videos, Radios, YouTube Videos & Telegram Video Files On Your Video Chat Of Channels & Groups !

Telegram Video Chat Bot (Beta) 📢 Video Chat Stream Telegram Bot 🤖 Can Stream Live Videos, Radios, YouTube Videos & Telegram Video Files On Your Vide

brut✘⁶⁹ // ユスフ 15 Dec 24, 2022
Free Game Download Client

XGames Free Game Download Client В проекте была использована библиотека igruha а также PyQt5 WARN ⚠️ Возможно потребуется скачать и установить vc_redi

LORD_CODE 3 Jun 25, 2022
An open source raffle bot made to increase the chance of winning limited sneaker raffles by automating entries.

🚀 SyneziaRaffles An open source raffle bot made to increase the chance of winning limited sneaker raffles by automating entries. 🏄‍♂️ Quick Start Pr

Alexis M. 29 Dec 22, 2022
The gPodder podcast client.

___ _ _ ____ __ _| _ \___ __| |__| |___ _ _ |__ / / _` | _/ _ \/ _` / _` / -_) '_| |_ \ \__, |_| \___/\__,_\__,_\___|_| |_

gPodder and related projects 1.1k Jan 04, 2023
Discord bot that manages expiration of roles with subscriptions!

Discord bot that manages expiration of roles with subscriptions!

Chakeaw__ 3 Apr 28, 2022
An example of matrix addition, demonstrating the basic method of Python calling C library functions

Example for Python call C functions An example of matrix addition, demonstrating the basic method of Python calling C library functions. How to run Bu

Quantum LIu 2 Dec 21, 2021
A very tiny python api for the stock exchange tradegate.de

pytradegate A very tiny python api for the stock exchange tradegate.de The api provides the recent ask/bid data and all other data as found on the det

dunderstr aka seimen 7 Aug 24, 2022
Recommended AWS CDK project structure for Python applications

Recommended AWS CDK project structure for Python applications The project implements a user management backend component that uses Amazon API Gateway,

AWS Samples 110 Jan 06, 2023