|
1 | | -# Amazon Product Advertising API 5.0 wrapper for Python |
| 1 | +# Python Amazon PAAPI |
2 | 2 |
|
3 | | -A simple Python wrapper for the [last version of the Amazon Product Advertising |
4 | | -API](https://webservices.amazon.com/paapi5/documentation/quick-start/using-sdk.html). |
5 | | -This module allows interacting with Amazon using the official API in an easier way. |
| 3 | +A simple Python wrapper for the [Amazon Product Advertising API 5.0](https://webservices.amazon.com/paapi5/documentation/). Easily interact with Amazon's official API to retrieve product information, search for items, and more. |
6 | 4 |
|
7 | 5 | [](https://pypi.org/project/python-amazon-paapi/) |
8 | | -[](https://www.python.org/) |
| 6 | +[](https://www.python.org/) |
9 | 7 | [](https://github.com/sergioteula/python-amazon-paapi/blob/master/LICENSE) |
10 | 8 | [](https://webservices.amazon.com/paapi5/documentation/) |
11 | | -[](https://pypi.org/project/python-amazon-paapi/) |
| 9 | +[](https://pypi.org/project/python-amazon-paapi/) |
12 | 10 |
|
13 | 11 | ## Features |
14 | 12 |
|
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/956f639b2ab3eab3f61644ae2ca8ae6500881312/amazon_paapi/models/regions.py#L1). |
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. |
25 | | -- Check the [documentation](https://python-amazon-paapi.readthedocs.io/en/latest/index.html) for reference. |
| 13 | +- 🎯 **Simple object-oriented interface** for easy integration |
| 14 | +- 🔍 **Product search** by keywords, categories, or browse nodes |
| 15 | +- 📦 **Product details** via ASIN or Amazon URL |
| 16 | +- 🔄 **Item variations** support (size, color, etc.) |
| 17 | +- 🌍 **20+ countries** supported ([full list](https://github.com/sergioteula/python-amazon-paapi/blob/master/amazon_paapi/models/regions.py)) |
| 18 | +- ⚡ **Batch requests** to get multiple items without the 10-item limit |
| 19 | +- 🛡️ **Built-in throttling** to avoid API rate limits |
| 20 | +- 📝 **Full type hints** for better IDE support |
26 | 21 |
|
27 | 22 | ## Installation |
28 | 23 |
|
29 | | -You can install or upgrade the module with: |
30 | | - |
31 | | - pip install python-amazon-paapi --upgrade |
32 | | - |
33 | | -## Usage guide |
| 24 | +```bash |
| 25 | +pip install python-amazon-paapi --upgrade |
| 26 | +``` |
34 | 27 |
|
35 | | -**Basic usage:** |
| 28 | +## Quick Start |
36 | 29 |
|
37 | 30 | ```python |
38 | 31 | from amazon_paapi import AmazonApi |
| 32 | + |
| 33 | +# Initialize the API (get credentials from Amazon Associates) |
39 | 34 | amazon = AmazonApi(KEY, SECRET, TAG, COUNTRY) |
| 35 | + |
| 36 | +# Get product information by ASIN |
40 | 37 | item = amazon.get_items('B01N5IB20Q')[0] |
41 | | -print(item.item_info.title.display_value) # Item title |
| 38 | +print(item.item_info.title.display_value) |
42 | 39 | ``` |
43 | 40 |
|
44 | | -**Get multiple items information:** |
| 41 | +## Usage Examples |
| 42 | + |
| 43 | +### Get Multiple Products |
45 | 44 |
|
46 | 45 | ```python |
47 | 46 | items = amazon.get_items(['B01N5IB20Q', 'B01F9G43WU']) |
48 | 47 | for item in items: |
49 | | - print(item.images.primary.large.url) # Primary image url |
50 | | - print(item.offers.listings[0].price.amount) # Current price |
| 48 | + print(item.images.primary.large.url) |
| 49 | + print(item.offers.listings[0].price.amount) |
51 | 50 | ``` |
52 | 51 |
|
53 | | -**Use URL insted of ASIN:** |
| 52 | +### Use Amazon URL Instead of ASIN |
54 | 53 |
|
55 | 54 | ```python |
56 | 55 | item = amazon.get_items('https://www.amazon.com/dp/B01N5IB20Q') |
57 | 56 | ``` |
58 | 57 |
|
59 | | -**Get item variations:** |
| 58 | +### Search Products |
60 | 59 |
|
61 | 60 | ```python |
62 | | -variations = amazon.get_variations('B01N5IB20Q') |
63 | | -for item in variations.items: |
64 | | - print(item.detail_page_url) # Affiliate url |
| 61 | +results = amazon.search_items(keywords='nintendo switch') |
| 62 | +for item in results.items: |
| 63 | + print(item.item_info.title.display_value) |
65 | 64 | ``` |
66 | 65 |
|
67 | | -**Search items:** |
| 66 | +### Get Product Variations |
68 | 67 |
|
69 | 68 | ```python |
70 | | -search_result = amazon.search_items(keywords='nintendo') |
71 | | -for item in search_result.items: |
72 | | - print(item.item_info.product_info.color) # Item color |
| 69 | +variations = amazon.get_variations('B01N5IB20Q') |
| 70 | +for item in variations.items: |
| 71 | + print(item.detail_page_url) |
73 | 72 | ``` |
74 | 73 |
|
75 | | -**Get browse node information:** |
| 74 | +### Get Browse Node Information |
76 | 75 |
|
77 | 76 | ```python |
78 | | -browse_nodes = amazon.get_browse_nodes(['667049031', '599385031']) |
79 | | -for browse_node in browse_nodes: |
80 | | - print(browse_node.display_name) # The name of the node |
| 77 | +nodes = amazon.get_browse_nodes(['667049031', '599385031']) |
| 78 | +for node in nodes: |
| 79 | + print(node.display_name) |
81 | 80 | ``` |
82 | 81 |
|
83 | | -**Get the ASIN from URL:** |
| 82 | +### Extract ASIN from URL |
84 | 83 |
|
85 | 84 | ```python |
86 | 85 | from amazon_paapi import get_asin |
| 86 | + |
87 | 87 | asin = get_asin('https://www.amazon.com/dp/B01N5IB20Q') |
| 88 | +# Returns: 'B01N5IB20Q' |
88 | 89 | ``` |
89 | 90 |
|
90 | | -**Throttling:** |
| 91 | +### Configure Throttling |
91 | 92 |
|
92 | | -Throttling value represents the wait time in seconds between API calls, being the |
93 | | -default value 1 second. Use it to avoid reaching Amazon request limits. |
| 93 | +Control the wait time between API calls to avoid rate limits: |
94 | 94 |
|
95 | 95 | ```python |
96 | | -amazon = AmazonApi(KEY, SECRET, TAG, COUNTRY, throttling=4) # Makes 1 request every 4 seconds |
97 | | -amazon = AmazonApi(KEY, SECRET, TAG, COUNTRY, throttling=0) # No wait time between requests |
| 96 | +# Wait 4 seconds between requests |
| 97 | +amazon = AmazonApi(KEY, SECRET, TAG, COUNTRY, throttling=4) |
| 98 | + |
| 99 | +# No throttling (use with caution) |
| 100 | +amazon = AmazonApi(KEY, SECRET, TAG, COUNTRY, throttling=0) |
98 | 101 | ``` |
99 | 102 |
|
100 | | -## Contribution |
| 103 | +## Documentation |
101 | 104 |
|
102 | | -Creating pull requests for this repo is higly appreciated to add new features or solve |
103 | | -bugs. To help during development process, githooks can be activated to run some scripts |
104 | | -before pushing new commits. This will run checks for code format and tests, to ensure |
105 | | -everything follows this repo guidelines. Use next command to activate them: |
| 105 | +- 📖 [Full Documentation](https://python-amazon-paapi.readthedocs.io/) |
| 106 | +- 📋 [Changelog](https://github.com/sergioteula/python-amazon-paapi/blob/master/CHANGELOG.md) |
| 107 | +- 💬 [Telegram Support Group](https://t.me/PythonAmazonPAAPI) |
106 | 108 |
|
| 109 | +## Contributing |
| 110 | + |
| 111 | +Contributions are welcome! To get started: |
| 112 | + |
| 113 | +1. Install [uv](https://docs.astral.sh/uv/) package manager |
| 114 | +2. Clone and set up the project: |
| 115 | + |
| 116 | +```bash |
| 117 | +git clone https://github.com/sergioteula/python-amazon-paapi.git |
| 118 | +cd python-amazon-paapi |
| 119 | +uv sync |
| 120 | +uv run pre-commit install |
107 | 121 | ``` |
108 | | -git config core.hooksPath .githooks |
109 | | -``` |
110 | 122 |
|
111 | | -The same checks will also run on the repo with GitHub Actions to ensure all tests pass |
112 | | -before merge. |
| 123 | +3. Copy `.env.template` to `.env` and add your Amazon API credentials for integration tests. |
| 124 | + |
| 125 | +Pre-commit hooks will automatically run Ruff, mypy, and tests before each commit. |
113 | 126 |
|
114 | 127 | ## License |
115 | 128 |
|
116 | | -Copyright © 2026 Sergio Abad. See |
117 | | -[license](https://github.com/sergioteula/python-amazon-paapi/blob/master/LICENSE) for |
118 | | -details. |
| 129 | +MIT License © 2026 [Sergio Abad](https://github.com/sergioteula) |
0 commit comments