Skip to content

Commit 3107f05

Browse files
committed
Merge branch 'dev-refactor' into develop
2 parents 21adc37 + ccde267 commit 3107f05

File tree

180 files changed

+20331
-8728
lines changed

Some content is hidden

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

180 files changed

+20331
-8728
lines changed

PRODUCT.md

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

README.md

Lines changed: 31 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
# Amazon Product Advertising API 5.0 wrapper for Python
22

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.
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).
12+
1113
## Features
1214

1315
- Object oriented interface for simple usage.
@@ -16,9 +18,8 @@ A simple Python wrapper for the [last version of the Amazon Product Advertising
1618
- Get browse nodes information.
1719
- Get multiple results at once without the 10 items limitation from Amazon.
1820
- Configurable throttling to avoid requests exceptions.
19-
- Built-in serializer for Django REST framework.
21+
- Type hints to help you coding.
2022
- Support for [all available countries](https://github.com/sergioteula/python-amazon-paapi/blob/master/amazon/paapi.py#L31).
21-
- Reorganized product information [structure](https://github.com/sergioteula/python-amazon-paapi/blob/master/PRODUCT.md) for simple use.
2223
- Ask for new features through the [issues](https://github.com/sergioteula/python-amazon-paapi/issues) section.
2324
- Join our [Telegram group](https://t.me/PythonAmazonPAAPI) for support or development.
2425

@@ -28,94 +29,72 @@ You can install or upgrade the module with:
2829

2930
pip install python-amazon-paapi --upgrade
3031

31-
If you get `ModuleNotFoundError`, try installing this:
32-
33-
pip install amightygirl.paapi5-python-sdk
34-
3532
## Usage guide
3633

3734
**Basic usage:**
3835

3936
```python
40-
from amazon.paapi import AmazonApi
37+
from amazon_paapi import AmazonApi
4138
amazon = AmazonApi(KEY, SECRET, TAG, COUNTRY)
42-
product = amazon.get_product('B01N5IB20Q')
43-
print(product.title)
39+
item = amazon.get_items('B01N5IB20Q')[0]
40+
print(item.item_info.title.display_value) # Item title
4441
```
4542

46-
**Get multiple product information:**
43+
**Get multiple items information:**
4744

4845
```python
49-
product = amazon.get_products('B01N5IB20Q,B01F9G43WU')
50-
print(product[0].images.large)
51-
print(product[1].prices.price.value)
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
5250
```
5351

5452
**Use URL insted of ASIN:**
5553

5654
```python
57-
product = amazon.get_product('https://www.amazon.com/dp/B01N5IB20Q')
55+
item = amazon.get_items('https://www.amazon.com/dp/B01N5IB20Q')
5856
```
5957

60-
**Get product variations:**
58+
**Get item variations:**
6159

6260
```python
63-
product = amazon.get_variations('B01N5IB20Q')
64-
print(product[0].title)
61+
variations = amazon.get_variations('B01N5IB20Q')
62+
for item in variations.items:
63+
print(item.detail_page_url) # Affiliate url
6564
```
6665

67-
**Search product:**
66+
**Search items:**
6867

6968
```python
70-
product = amazon.search_products(item_count=25, keywords='speaker')
71-
print(product[14].url)
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
7272
```
7373

7474
**Get browse node information:**
7575

7676
```python
77-
node = amazon.get_browsenodes(browse_nodes=browsenodes_list)
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
7880
```
7981

80-
**Get the ASIN from a URL:**
82+
**Get the ASIN from URL:**
8183

8284
```python
83-
from amazon.tools import get_asin
85+
from amazon_paapi import get_asin
8486
asin = get_asin('https://www.amazon.com/dp/B01N5IB20Q')
8587
```
8688

8789
**Throttling:**
8890

89-
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.
90-
91-
```python
92-
amazon = AmazonApi(KEY, SECRET, TAG, COUNTRY, throttling=0.5) # Max one request every two seconds
93-
amazon = AmazonApi(KEY, SECRET, TAG, COUNTRY, throttling=False) # Unlimited requests per second
94-
```
95-
96-
**Serializer for Django:**
97-
98-
We provide a serializer for Django REST framework, which speeds up your API
99-
implementation.
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.
10092

10193
```python
102-
from amazon.serializers import AmazonProductSerializer
103-
from rest_framework import serializers
104-
105-
serialized_product = AmazonProductSerializer(product)
106-
serialized_product.data
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
10796
```
10897

109-
If you want to serialize a list of products:
110-
111-
```python
112-
serialized_products = AmazonProductSerializer(products, many=True)
113-
serialized_products.data
114-
```
115-
116-
For more information on how to work with serializers, check the documentation for
117-
[Django REST framework](https://www.django-rest-framework.org/api-guide/serializers/).
118-
11998
## License
12099

121-
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)