Skip to main content

A Python Library for interacting with the Amazon Product Advertising API.

Project description

## orangearrow

### A Python library for interacting with the Amazon Product Advertising API.

#### What is it?

[orangearrow](https://github.com/wreddily/orangearrow) is a Python library that simplifies usage of the [Amazon Product Advertising API](https://docs.aws.amazon.com/AWSECommerceService/latest/GSG/Welcome.html). It aims to be easy to use, flexible and gets out of your way when you need it to.

#### What do I need to get started?

You will need an Amazon Associate Tag and Amazon API credentials. All of that is covered [here](https://docs.aws.amazon.com/AWSECommerceService/latest/DG/becomingDev.html).

#### How do I use it?

To use Search or Lookup functionality, first create an instance of the `AmazonProductAPI` class. You will need to pass your Amazon API credentials like so:

from orangearrow import AmazonProductAPI

amazon_api = AmazonProductAPI(
access_key='AKIAIOSFODNN7EXAMPLE',
secret_key='1234567890',
associate_tag='mytag-20'
)

##### Search

To search for items, use the `item_search` method with a valid [Search Index](https://docs.aws.amazon.com/AWSECommerceService/latest/DG/LocaleUS.html) and a list of keywords:

search_response = amazon_api.item_search(
'Electronics',
['Television', 'Flatscreen',]
)

You can also optionally pass a `page` parameter to paginate results:

search_response = amazon_api.item_search(
'Electronics',
['Television', 'Flatscreen',],
page=2
)

As well as specifying [Response Groups](https://docs.aws.amazon.com/AWSECommerceService/latest/DG/CHAP_ResponseGroupsList.html) to filter the information that you want returned:

search_response = amazon_api.item_search(
'Electronics',
['Television', 'Flatscreen',],
page=2,
response_groups=['Variations', 'Reviews',],
)

To customize the request even further, you can add any [ItemSearch parameters supported by the Amazon API](https://docs.aws.amazon.com/AWSECommerceService/latest/DG/ItemSearch.html#ItemSearch-rp) into a `parameters` dictionary:

search_response = amazon_api.item_search(
'Electronics',
['Television', 'Flatscreen',],
parameters={
'Brand': 'Sony',
'MaximumPrice': '50000',
}
)

##### Item Lookup

The `item_lookup` method can be used to look up individual items by their ASIN ID:

product_response = amazon_api.item_lookup('B07D4FQB8S')

Or by a different supported [IdType](https://docs.aws.amazon.com/AWSECommerceService/latest/DG/ItemLookup.html) and [Search Index](https://docs.aws.amazon.com/AWSECommerceService/latest/DG/LocaleUS.html):

product_response = amazon_api.item_lookup(
'602498631416',
search_index='Music',
id_type='UPC'
)

Similar to the `search` method, `response_groups` and extra `parameters` supported by [ItemSearch](https://docs.aws.amazon.com/AWSECommerceService/latest/DG/ItemLookup.html#ItemLookup-rp) may also be used:

product_response = amazon_api.item_lookup(
'602498631416',
search_index='Music',
id_type='UPC',
response_groups=['Reviews'],
parameters={'TruncateReviewsAt': 200}
)

##### Similarity Lookup

The `similarity_lookup` method can be used to find similar items for one or more ASIN values:

similarities_response = amazon_api.similarity_lookup(['B00JFC9ALE', 'B06XY1YTMJ'])

This method will also accept `response_groups` and additional `parameters` that are supported by [Similarity Lookup](https://docs.aws.amazon.com/AWSECommerceService/latest/DG/SimilarityLookup.html#SimilarityLookup-rp):

similarities_response = amazon_api.similarity_lookup(
['B00JFC9ALE', 'B06XY1YTMJ'],
response_groups=['EditorialReview'],
parameters={'MerchantId': 'Amazon'}
)

##### Responses

In the Search and Lookup examples above, an instance of `AmazonProductAPIResponse` will be returned. The returned data can be accessed in a dictionary via the `data` property of the response:

search_response.data

Or the raw XML can be accessed via the `raw_response_content` property:

search_response.raw_response_content

If any errors occurred, the following properties will contain error information:

search_response.is_error
search_response.error_code
search_response.error_msg

The instance will also contain the response's status code and headers:

search_response.status_code
search_response.headers



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

orangearrow-0.9.64.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

orangearrow-0.9.64-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file orangearrow-0.9.64.tar.gz.

File metadata

  • Download URL: orangearrow-0.9.64.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/20.7.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.5.2

File hashes

Hashes for orangearrow-0.9.64.tar.gz
Algorithm Hash digest
SHA256 181c770459a33e4475b30a3522f1ce4f4054d5b8021298c59deba909f9507b25
MD5 9cb4ea69520c510ff760dd9c95b1c524
BLAKE2b-256 09ee274602d48b4f295fa7543343a4ea4e91fe3aa0ba53d128e56cdc4085c580

See more details on using hashes here.

File details

Details for the file orangearrow-0.9.64-py3-none-any.whl.

File metadata

  • Download URL: orangearrow-0.9.64-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/20.7.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.5.2

File hashes

Hashes for orangearrow-0.9.64-py3-none-any.whl
Algorithm Hash digest
SHA256 7d012dc72ff0b7182bce424122e47c83402f50bb9b0a529a2b4d5acbf428701a
MD5 231b569f71a3576374db0222725cf45c
BLAKE2b-256 afc7594dac53f0f771b0a8dfd9ac35973b6c2de7b79d6f1d11ec2a7d0fdadff9

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