Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
orangearrow is a Python library that simplifies usage of the Amazon Product Advertising API. It aims to be easy to use, flexible and gets out of your way when you need it to.
You will need an Amazon Associate Tag and Amazon API credentials. All of that is covered here.
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'
)
To search for items, use the item_search
method with a valid Search Index 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 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 into a parameters
dictionary:
search_response = amazon_api.item_search(
'Electronics',
['Television', 'Flatscreen',],
parameters={
'Brand': 'Sony',
'MaximumPrice': '50000',
}
)
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 and Search Index:
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 may also be used:
product_response = amazon_api.item_lookup(
'602498631416',
search_index='Music',
id_type='UPC',
response_groups=['Reviews'],
parameters={'TruncateReviewsAt': 200}
)
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:
similarities_response = amazon_api.similarity_lookup(
['B00JFC9ALE', 'B06XY1YTMJ'],
response_groups=['EditorialReview'],
parameters={'MerchantId': 'Amazon'}
)
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
FAQs
A Python Library for interacting with the Amazon Product Advertising API.
We found that orangearrow demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.