Skip to content

Commit 956f639

Browse files
committed
Merge branch 'develop'
2 parents 5ce054f + 3107f05 commit 956f639

File tree

226 files changed

+20654
-8295
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

226 files changed

+20654
-8295
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Custom folders and files to ignore
22
.vscode/
33
.DS_Store
4+
secrets.py
45

56

67
# Byte-compiled / optimized / DLL files

PRODUCT.md

Lines changed: 0 additions & 128 deletions
This file was deleted.

README.md

Lines changed: 62 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,124 +1,100 @@
1-
Amazon Product Advertising API 5.0 wrapper for Python
2-
=======================================================
3-
A simple Python wrapper for the [last version of the Amazon Product Advertising API](https://webservices.amazon.com/paapi5/documentation/quick-start/using-sdk.html). This module allows to get product information from Amazon using the official API in an easier way.
1+
# Amazon Product Advertising API 5.0 wrapper for Python
2+
3+
A simple Python wrapper for the [last version of the Amazon Product Advertising API](https://webservices.amazon.com/paapi5/documentation/quick-start/using-sdk.html). This module allows interacting with Amazon using the official API in an easier way.
44

55
[![PyPI](https://img.shields.io/pypi/v/python-amazon-paapi?color=%231182C2&label=PyPI)](https://pypi.org/project/python-amazon-paapi/)
6-
[![Python](https://img.shields.io/badge/Python-2.x%20%7C%203.x-%23FFD140)](https://www.python.org/)
6+
[![Python](https://img.shields.io/badge/Python->3.6-%23FFD140)](https://www.python.org/)
77
[![License](https://img.shields.io/badge/License-MIT-%23e83633)](https://github.com/sergioteula/python-amazon-paapi/blob/master/LICENSE)
88
[![Support](https://img.shields.io/badge/Support-Good-brightgreen)](https://github.com/sergioteula/python-amazon-paapi/issues)
99
[![Amazon API](https://img.shields.io/badge/Amazon%20API-5.0-%23FD9B15)](https://webservices.amazon.com/paapi5/documentation/)
1010

11+
> If you are still using the old version, go [here](https://github.com/sergioteula/python-amazon-paapi/blob/master/amazon/README).
1112
12-
Features
13-
--------
13+
## Features
1414

15-
* Object oriented interface for simple usage.
16-
* Get information about a product through its ASIN or URL.
17-
* Get item variations or search for products on Amazon.
18-
* Get browse nodes information.
19-
* Get multiple results at once without the 10 items limitation from Amazon.
20-
* Configurable throttling to avoid requests exceptions.
21-
* Built-in serializer for Django REST framework.
22-
* Support for [all available countries](https://github.com/sergioteula/python-amazon-paapi/blob/master/amazon/paapi.py#L31).
23-
* Reorganized product information [structure](https://github.com/sergioteula/python-amazon-paapi/blob/master/PRODUCT.md) for simple use.
24-
* Ask for new features through the [issues](https://github.com/sergioteula/python-amazon-paapi/issues) section.
25-
* Join our [Telegram group](https://t.me/PythonAmazonPAAPI) for support or development.
15+
- Object oriented interface for simple usage.
16+
- Get information about a product through its ASIN or URL.
17+
- Get item variations or search for products on Amazon.
18+
- Get browse nodes information.
19+
- Get multiple results at once without the 10 items limitation from Amazon.
20+
- Configurable throttling to avoid requests exceptions.
21+
- Type hints to help you coding.
22+
- Support for [all available countries](https://github.com/sergioteula/python-amazon-paapi/blob/master/amazon/paapi.py#L31).
23+
- Ask for new features through the [issues](https://github.com/sergioteula/python-amazon-paapi/issues) section.
24+
- Join our [Telegram group](https://t.me/PythonAmazonPAAPI) for support or development.
2625

27-
Installation
28-
-------------
26+
## Installation
2927

3028
You can install or upgrade the module with:
3129

3230
pip install python-amazon-paapi --upgrade
3331

34-
If you get `ModuleNotFoundError`, try installing this:
35-
36-
pip install amightygirl.paapi5-python-sdk
32+
## Usage guide
3733

38-
Usage guide
39-
-----------
4034
**Basic usage:**
4135

42-
````python
43-
from amazon.paapi import AmazonAPI
44-
amazon = AmazonAPI(KEY, SECRET, TAG, COUNTRY)
45-
product = amazon.get_product('B01N5IB20Q')
46-
print(product.title)
47-
````
36+
```python
37+
from amazon_paapi import AmazonApi
38+
amazon = AmazonApi(KEY, SECRET, TAG, COUNTRY)
39+
item = amazon.get_items('B01N5IB20Q')[0]
40+
print(item.item_info.title.display_value) # Item title
41+
```
4842

49-
**Get multiple product information:**
43+
**Get multiple items information:**
5044

51-
````python
52-
product = amazon.get_products('B01N5IB20Q,B01F9G43WU')
53-
print(product[0].images.large)
54-
print(product[1].prices.price.value)
55-
````
45+
```python
46+
items = amazon.get_items(['B01N5IB20Q', 'B01F9G43WU'])
47+
for item in items:
48+
print(item.images.primary.large.url) # Primary image url
49+
print(item.offers.listings[0].price.amount) # Current price
50+
```
5651

5752
**Use URL insted of ASIN:**
5853

59-
````python
60-
product = amazon.get_product('https://www.amazon.com/dp/B01N5IB20Q')
61-
````
54+
```python
55+
item = amazon.get_items('https://www.amazon.com/dp/B01N5IB20Q')
56+
```
6257

63-
**Get product variations:**
58+
**Get item variations:**
6459

65-
````python
66-
product = amazon.get_variations('B01N5IB20Q')
67-
print(product[0].title)
68-
````
60+
```python
61+
variations = amazon.get_variations('B01N5IB20Q')
62+
for item in variations.items:
63+
print(item.detail_page_url) # Affiliate url
64+
```
6965

70-
**Search product:**
66+
**Search items:**
7167

72-
````python
73-
product = amazon.search_products(item_count=25, keywords='speaker')
74-
print(product[14].url)
75-
````
68+
```python
69+
search_result = amazon.search_items(keywords='nintendo')
70+
for item in search_result.items:
71+
print(item.item_info.product_info.color) # Item color
72+
```
7673

7774
**Get browse node information:**
7875

79-
````python
80-
node = amazon.get_browsenodes(browse_nodes=browsenodes_list)
81-
````
76+
```python
77+
browse_nodes = amazon.get_browse_nodes(['667049031', '599385031'])
78+
for browse_node in browse_nodes:
79+
print(browse_node.display_name) # The name of the node
80+
```
8281

83-
**Get the ASIN from a URL:**
82+
**Get the ASIN from URL:**
8483

85-
````python
86-
from amazon.tools import get_asin
84+
```python
85+
from amazon_paapi import get_asin
8786
asin = get_asin('https://www.amazon.com/dp/B01N5IB20Q')
88-
````
87+
```
8988

9089
**Throttling:**
9190

92-
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](https://github.com/sergioteula/python-amazon-paapi/blob/master/amazon/paapi.py#L36) to `0.8` or one request every 1.25 seconds.
93-
94-
````python
95-
amazon = AmazonAPI(KEY, SECRET, TAG, COUNTRY, throttling=0.5) # Max one request every two seconds
96-
amazon = AmazonAPI(KEY, SECRET, TAG, COUNTRY, throttling=False) # Unlimited requests per second
97-
````
98-
99-
**Serializer for Django:**
100-
101-
We provide a serializer for Django REST framework, which speeds up your API
102-
implementation.
103-
104-
````python
105-
from amazon.serializers import AmazonProductSerializer
106-
from rest_framework import serializers
107-
108-
serialized_product = AmazonProductSerializer(product)
109-
serialized_product.data
110-
````
111-
112-
If you want to serialize a list of products:
91+
Throttling value represents the wait time in seconds between API calls, being the default value 1 second. Use it to avoid reaching Amazon request limits.
11392

114-
````python
115-
serialized_products = AmazonProductSerializer(products, many=True)
116-
serialized_products.data
117-
````
93+
```python
94+
amazon = AmazonApi(KEY, SECRET, TAG, COUNTRY, throttling=4) # Makes 1 request every 4 seconds
95+
amazon = AmazonApi(KEY, SECRET, TAG, COUNTRY, throttling=0) # No wait time between requests
96+
```
11897

119-
For more information on how to work with serializers, check the documentation for
120-
[Django REST framework](https://www.django-rest-framework.org/api-guide/serializers/).
98+
## License
12199

122-
License
123-
-------------
124-
Copyright © 2020 Sergio Abad. See [license](https://github.com/sergioteula/python-amazon-paapi/blob/master/LICENSE) for details.
100+
Copyright © 2021 Sergio Abad. See [license](https://github.com/sergioteula/python-amazon-paapi/blob/master/LICENSE) for details.

0 commit comments

Comments
 (0)