Giter Site home page Giter Site logo

amazon-paapi5's Introduction

Amazon Product Advertising API 5.0 wrapper for Python

A simple Python wrapper for the last version of the Amazon Product Advertising API. This module allows to get product information from Amazon using the official API in an easier way. Like Bottlenose you can use cache reader and writer to limit the number of api calls.

PyPI Python GitHub Support Amazon API PyPI - Wheel Documentation Status

Features

  • Object oriented interface for simple usage
  • Get multiple products at once
  • Configurable query caching
  • Compatible with Python versions 3.6 and up
  • Support for AU, BR, CA, FR, IN, IT, JP, MX, ES, TR, MX, AE, UK and US Amazon Product Advertising API endpoints
  • Configurable throttling for batches of queries
  • Ask for new features through the issues section.
  • Full documentation on Read the Docs

Installation

You can install or upgrade the module with:

pip install amazon-paapi5 --upgrade

Usage guide

Search items::

from amazon.paapi import AmazonAPI
amazon = AmazonAPI(KEY, SECRET, TAG, COUNTRY)
products = amazon.search_items(keywords='harry potter')
print(product['data'][0].image_large)
print(product['data'][1].prices.price)

Get multiple products information::

from amazon.paapi import AmazonAPI
amazon = AmazonAPI(KEY, SECRET, TAG, COUNTRY)
products = amazon.get_items(item_ids=['B01N5IB20Q','B01F9G43WU'])
print(products['data']['B01N5IB20Q'].image_large)
print(products['data']['B01F9G43WU'].prices.price)

Get variations::

from amazon.paapi import AmazonAPI
amazon = AmazonAPI(KEY, SECRET, TAG, COUNTRY)
products = amazon.get_variations(asin=['B01N5IB20Q','B01F9G43WU'])

Get browse nodes::

from amazon.paapi import AmazonAPI
amazon = AmazonAPI(KEY, SECRET, TAG, COUNTRY)
browseNodes = amazon.get_browse_nodes(browse_node_ids=['473535031'])

Use cache reader and writer::

from amazon.paapi import AmazonAPI

DATA = []

def custom_save_function(url, data, http_info):  
    DATA.append({'url':url, 'data': data, 'http_info':http_info}) 

def custom_retrieval_function(url):  
    for item in DATA:  
        if item["url"] == url: 
            return {'data':item['data'], 'http_info': item['http_info']}  
    return None

amazon = AmazonAPI(KEY, SECRET, TAG, COUNTRY, CacheReader=custom_retrieval_function, CacheWriter=custom_save_function) 
products = amazon.search_items(keywords='harry potter')

Changelog

Version 1.1.2
    - License MIT
Version 1.1.1
    - add additional parameters to api calls
Version 1.1.0
    - CacheReader and CacheWriter available for all the search functions
    - Defintion af AmazonException to get exceptions during the api calls
    - Constants defintion
    - AmazonProduct and AmazonBrowseNode definition
    - Uniform data structure returned by all the api calls
Version 1.0.0
    - CacheReader and CacheWriter
    - Enable throttling
Version 0.1.0
    - First release

Buy Me A Coffee

amazon-paapi5's People

Contributors

alefiori82 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

Watchers

 avatar  avatar  avatar

amazon-paapi5's Issues

ciao

come facio a instalare il tuo pacheto sul progeto di samir puoi inserirlo tu e mi passi il tutto tramiìte zip se vuio ti passo telegram cosi ci sentiamo li ?

InvalidSignatureException

[ERROR/2020-03-03 04:18:14,870] root: (ApiException)
Reason: {"__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.es/paapi5/documentation/sending-request.html#signing."}]}

My device timezone is UTC.
Accessing Spain (ES) marketplace.

Savings returned are not present in product's page

I'm using this library connecting to the 'IT' region, using standard AWS credentials (id, secret and tag).

Some of the products returned contain a 'ghost' saving that's not shown in Amazon's page.

Let's take for example this product:

https://www.amazon.it/dp/B07WP5RDM2?tag=sshopping-21&linkCode=osi&th=1&psc=1

                          'price': {'amount': 9.99,
                                    'currency': 'EUR',
                                    'display_amount': '9,99\xa0€',
                                    'price_per_unit': None,
                                    'savings': {'amount': 20.0,
                                                'currency': 'EUR',
                                                'display_amount': '20,00\xa0€ '
                                                                  '(67%)',
                                                'percentage': 67,
                                                'price_per_unit': None}},

The full price should be 29.99, with a discount of 67%. In reality 9.99 is the full price shown and no discount is reported.

The code I'm using to recover this product is:
results = client.search_items( item_count=10, item_page=1, keywords="ELEFULL 10000mAh Power Bank Caricatore Portatile,2 USB Batteria Esterna con LED Digitale Display per Telefoni Moible, Tablet e Altro" )

I've uploaded the full output for convenience: https://gist.github.com/aegroto/e0ed6b85ce0f70add503584e49605b60

help

guys to me from this mistake can you help me?

Status code: 401
Errors : {"__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."}]}
Request ID:
INFO:root:'NoneType' object is not iterable
Error calling PA-API 5.0!
Status code: 401
Errors : {"__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."}]}
Request ID:b
INFO:root:'NoneType' object is not iterable

Error in the README.md

The Example :
products = amazon.search_items(keywords='harry potter')
print(product['data'][0].image_large)
print(product['data'][1].prices.price)

Doesn't work

This works :
products = amazon.search_items(keywords='harry potter')
print(products['data'][0].image_large)
print(products['data'][1].prices.price)

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.