Skip to main content

Amazon Product Advertising API 5.0 wrapper for Python

Project description

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.

PyPI Python License Support Amazon API

Features

  • Object oriented interface for simple usage.
  • Get information about a product through its ASIN or URL.
  • Get item variations or search for products on Amazon.
  • Get browse nodes information.
  • Get multiple results at once without the 10 items limitation from Amazon.
  • Configurable throttling to avoid requests exceptions.
  • Built-in serializer for Django REST framework.
  • Support for all available countries.
  • Reorganized product information structure for simple use.
  • Ask for new features through the issues section.
  • Join our Telegram group for support or development.

Installation

You can install or upgrade the module with:

pip install python-amazon-paapi --upgrade

If you get ModuleNotFoundError, try installing this:

pip install amightygirl.paapi5-python-sdk

Usage guide

Basic usage:

from amazon.paapi import AmazonAPI
amazon = AmazonAPI(KEY, SECRET, TAG, COUNTRY)
product = amazon.get_product('B01N5IB20Q')
print(product.title)

Get multiple product information:

product = amazon.get_products('B01N5IB20Q,B01F9G43WU')
print(product[0].images.large)
print(product[1].prices.price.value)

Use URL insted of ASIN:

product = amazon.get_product('https://www.amazon.com/dp/B01N5IB20Q')

Get product variations:

product = amazon.get_variations('B01N5IB20Q')
print(product[0].title)

Search product:

product = amazon.search_products(item_count=25, keywords='speaker')
print(product[14].url)

Get browse node information:

node = amazon.get_browsenodes(browse_nodes=browsenodes_list)

Get the ASIN from a URL:

from amazon.tools import get_asin
asin = get_asin('https://www.amazon.com/dp/B01N5IB20Q')

Throttling:

Throttling value must be greater than 0 or False to disable it. This value throttles requests to a maximum of one request every 1 / value seconds. Note that this value is a per-worker throttling, so applications with multiple workers may make more requests per second. Throttling value is set by default to 0.8 or one request every 1.25 seconds.

amazon = AmazonAPI(KEY, SECRET, TAG, COUNTRY, throttling=0.5)  # Max one request every two seconds
amazon = AmazonAPI(KEY, SECRET, TAG, COUNTRY, throttling=False)  # Unlimited requests per second

Serializer for Django:

We provide a serializer for Django REST framework, which speeds up your API implementation.

from amazon.serializers import AmazonProductSerializer
from rest_framework import serializers

serialized_product = AmazonProductSerializer(product)
serialized_product.data

If you want to serialize a list of products:

serialized_products = AmazonProductSerializer(products, many=True)
serialized_products.data

For more information on how to work with serializers, check the documentation for Django REST framework.

License

Copyright © 2020 Sergio Abad. 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

python-amazon-paapi-3.3.4.tar.gz (62.3 kB view hashes)

Uploaded Source

Built Distribution

python_amazon_paapi-3.3.4-py3-none-any.whl (181.5 kB view hashes)

Uploaded Python 3

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