Skip to content

Commit 07be5e9

Browse files
authored
Merge pull request #142 from sergioteula/add-creators-api-compatibility
Add Amazon Creators API Compatibility
2 parents 20de236 + 41ab854 commit 07be5e9

File tree

135 files changed

+16068
-284
lines changed

Some content is hidden

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

135 files changed

+16068
-284
lines changed

.env.template

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1+
# Product Advertising API
12
API_KEY=
23
API_SECRET=
4+
5+
# Creators API
6+
CREDENTIAL_ID=
7+
CREDENTIAL_SECRET=
8+
API_VERSION=
9+
MARKETPLACE=
10+
11+
# Common
312
AFFILIATE_TAG=
413
COUNTRY_CODE=

.github/workflows/check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ jobs:
7474
strategy:
7575
fail-fast: false
7676
matrix:
77-
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14", "3.15"]
77+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
7878

7979
steps:
8080
- uses: actions/checkout@v5

.pre-commit-config.yaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ repos:
1515
rev: v6.0.0
1616
hooks:
1717
- id: trailing-whitespace
18+
exclude: ^creatorsapi_python_sdk/
1819
- id: end-of-file-fixer
20+
exclude: ^creatorsapi_python_sdk/
1921
- id: mixed-line-ending
2022
- id: check-yaml
2123
- id: check-added-large-files
@@ -38,18 +40,19 @@ repos:
3840
hooks:
3941
- id: gitleaks
4042

41-
- repo: https://github.com/pre-commit/mirrors-mypy
42-
rev: "v1.19.1"
43+
- repo: local
4344
hooks:
4445
- id: mypy
45-
exclude: sdk/
46+
name: checking types with mypy
47+
entry: uv run mypy .
48+
language: system
49+
types: [python]
50+
pass_filenames: false
4651

47-
- repo: local
48-
hooks:
4952
- id: test
5053
name: Running tests
5154
language: system
52-
entry: "bash -c 'set -a && source .env 2>/dev/null; set +a && uv run pytest -rs --cov=amazon_paapi'"
55+
entry: "bash -c 'set -a && source .env 2>/dev/null; set +a && uv run pytest -rs --cov=amazon_paapi --cov=amazon_creatorsapi'"
5356
types_or: [python]
5457
pass_filenames: false
5558

CHANGELOG.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,33 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [6.0.0] - 2026-01-29
9+
10+
### Added
11+
12+
- New `amazon_creatorsapi` module for Amazon Creators API support
13+
- `creatorsapi_python_sdk` package bundled for OAuth2 authentication
14+
- `models` submodule exposing all SDK model classes (Item, Condition, SortBy, etc.)
15+
- Migration guide from PAAPI to Creators API (`docs/pages/migration-guide-6.md`)
16+
- Integration tests for the new Creators API module
17+
- New dependencies: `pydantic>=2.0.0` and `requests>=2.28.0`
18+
19+
### Changed
20+
21+
- **BREAKING**: The `amazon_paapi` module is now deprecated in favor of `amazon_creatorsapi`
22+
- Updated documentation to reflect the new Creators API module
23+
- Reorganized utility functions into `amazon_creatorsapi.core` package
24+
- Updated README with Creators API examples and deprecation notice
25+
26+
### Deprecated
27+
28+
- `amazon_paapi` module - use `amazon_creatorsapi` instead
29+
- All PAAPI-specific documentation pages removed
30+
31+
### Removed
32+
33+
- Migration guides for versions 4 and 5 (`migration-guide-4.md`, `migration-guide-5.md`)
34+
835
## [5.2.0] - 2026-01-11
936

1037
### Added

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export UID:=$(shell id -u)
22
export GID:=$(shell id -g)
33

4-
export PYTHON_TAGS = 3.9 3.10 3.11 3.12 3.13 3.14 3.15
4+
export PYTHON_TAGS = 3.9 3.10 3.11 3.12 3.13 3.14
55

66
setup:
77
@uv run pre-commit install
@@ -11,7 +11,7 @@ test:
1111
@uv run --env-file .env pytest -rs
1212

1313
coverage:
14-
@uv run pytest -rs --cov=amazon_paapi --cov-report=html --cov-report=term --cov-report=xml
14+
@uv run pytest -rs --cov=amazon_paapi --cov=amazon_creatorsapi --cov-report=html --cov-report=term --cov-report=xml
1515

1616
test-all-python-tags:
1717
@touch .env
@@ -22,6 +22,9 @@ test-all-python-tags:
2222
lint:
2323
@uv run ruff check --fix .
2424

25+
format:
26+
@uv run ruff format .
27+
2528
mypy:
2629
@uv run mypy .
2730

README.md

Lines changed: 77 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1-
# Python Amazon PAAPI
1+
# Python Amazon Creators API
22

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.
3+
A Python wrapper for Amazon's product APIs. This package supports both the legacy [Product Advertising API 5.0](https://webservices.amazon.com/paapi5/documentation/) and the new [Amazon Creators API](https://webservices.amazon.com/creatorsapi/documentation/).
44

55
[![PyPI](https://img.shields.io/pypi/v/python-amazon-paapi?color=%231182C2&label=PyPI)](https://pypi.org/project/python-amazon-paapi/)
66
[![Python](https://img.shields.io/badge/Python-≥3.9-%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)
8-
[![Amazon API](https://img.shields.io/badge/Amazon%20API-5.0-%23FD9B15)](https://webservices.amazon.com/paapi5/documentation/)
98
[![Downloads](https://img.shields.io/pypi/dm/python-amazon-paapi?label=Downloads)](https://pypi.org/project/python-amazon-paapi/)
109

10+
> [!IMPORTANT]
11+
> **Migration Advisory**: The `amazon_paapi` module is deprecated. Amazon is transitioning from the Product Advertising API (PAAPI) to the new **Creators API**. Please migrate to the `amazon_creatorsapi` module for new projects. See the [Migration Guide](https://python-amazon-paapi.readthedocs.io/en/latest/pages/migration-guide-6.html) for more information.
12+
1113
## Features
1214

1315
- 🎯 **Simple object-oriented interface** for easy integration
1416
- 🔍 **Product search** by keywords, categories, or browse nodes
1517
- 📦 **Product details** via ASIN or Amazon URL
1618
- 🔄 **Item variations** support (size, color, etc.)
1719
- 💰 **OffersV2 support** for enhanced pricing and offer details
18-
- 🌍 **20+ countries** supported ([full list](https://github.com/sergioteula/python-amazon-paapi/blob/master/amazon_paapi/models/regions.py))
19-
-**Batch requests** to get multiple items without the 10-item limit
20+
- 🌍 **20+ countries** supported
2021
- 🛡️ **Built-in throttling** to avoid API rate limits
2122
- 📝 **Full type hints** for better IDE support
2223

@@ -26,93 +27,124 @@ A simple Python wrapper for the [Amazon Product Advertising API 5.0](https://web
2627
pip install python-amazon-paapi --upgrade
2728
```
2829

30+
---
31+
2932
## Quick Start
3033

3134
```python
32-
from amazon_paapi import AmazonApi
35+
from amazon_creatorsapi import AmazonCreatorsApi, Country
3336

34-
# Initialize the API (get credentials from Amazon Associates)
35-
amazon = AmazonApi(KEY, SECRET, TAG, COUNTRY)
37+
# Initialize with your Creators API credentials
38+
api = AmazonCreatorsApi(
39+
credential_id="your_credential_id",
40+
credential_secret="your_credential_secret",
41+
version="2.2",
42+
tag="your-affiliate-tag",
43+
country=Country.US,
44+
)
3645

3746
# Get product information by ASIN
38-
item = amazon.get_items('B01N5IB20Q')[0]
39-
print(item.item_info.title.display_value)
47+
items = api.get_items(["B01N5IB20Q"])
48+
print(items[0].item_info.title.display_value)
49+
50+
# Or use Amazon URLs directly
51+
items = api.get_items(["https://www.amazon.com/dp/B01N5IB20Q"])
4052
```
4153

4254
## Usage Examples
4355

44-
### Using OffersV2 resources
45-
46-
OffersV2 provides enhanced pricing and offer details. All resources are included by default, so OffersV2 data is available without any additional configuration:
47-
48-
```python
49-
item = amazon.get_items('B01N5IB20Q')[0]
50-
if item.offers_v2 and item.offers_v2.listings:
51-
listing = item.offers_v2.listings[0]
52-
print(listing.price.money.amount) # Price amount
53-
print(listing.merchant_info.name) # Merchant name
54-
```
55-
56-
### Get Multiple Products
56+
### Get Multiple Items
5757

5858
```python
59-
items = amazon.get_items(['B01N5IB20Q', 'B01F9G43WU'])
59+
items = api.get_items(["B01N5IB20Q", "B01F9G43WU"])
6060
for item in items:
6161
print(item.images.primary.large.url)
62-
print(item.offers.listings[0].price.amount)
63-
```
64-
65-
### Use Amazon URL Instead of ASIN
66-
67-
```python
68-
item = amazon.get_items('https://www.amazon.com/dp/B01N5IB20Q')
6962
```
7063

7164
### Search Products
7265

7366
```python
74-
results = amazon.search_items(keywords='nintendo switch')
67+
results = api.search_items(keywords="nintendo switch")
7568
for item in results.items:
7669
print(item.item_info.title.display_value)
7770
```
7871

7972
### Get Product Variations
8073

8174
```python
82-
variations = amazon.get_variations('B01N5IB20Q')
75+
# Using ASIN
76+
variations = api.get_variations("B01N5IB20Q")
77+
78+
# Or using Amazon URL
79+
variations = api.get_variations("https://www.amazon.com/dp/B01N5IB20Q")
80+
8381
for item in variations.items:
8482
print(item.detail_page_url)
8583
```
8684

8785
### Get Browse Node Information
8886

8987
```python
90-
nodes = amazon.get_browse_nodes(['667049031', '599385031'])
88+
nodes = api.get_browse_nodes(["667049031"])
9189
for node in nodes:
9290
print(node.display_name)
9391
```
9492

95-
### Extract ASIN from URL
93+
### Get the ASIN from URL
9694

9795
```python
98-
from amazon_paapi import get_asin
96+
from amazon_creatorsapi import get_asin
9997

100-
asin = get_asin('https://www.amazon.com/dp/B01N5IB20Q')
101-
# Returns: 'B01N5IB20Q'
98+
asin = get_asin("https://www.amazon.com/dp/B01N5IB20Q")
10299
```
103100

104-
### Configure Throttling
101+
### Using OffersV2 Resources
102+
103+
```python
104+
items = api.get_items(["B01N5IB20Q"])
105+
item = items[0]
106+
if item.offers_v2 and item.offers_v2.listings:
107+
listing = item.offers_v2.listings[0]
108+
print(listing.price.money.amount)
109+
print(listing.merchant_info.name)
110+
```
105111

106-
Control the wait time between API calls to avoid rate limits:
112+
### Throttling
113+
114+
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.
107115

108116
```python
109-
# Wait 4 seconds between requests
110-
amazon = AmazonApi(KEY, SECRET, TAG, COUNTRY, throttling=4)
117+
amazon = AmazonCreatorsApi(ID, SECRET, VERSION, TAG, COUNTRY, throttling=4) # Makes 1 request every 4 seconds
118+
amazon = AmazonCreatorsApi(ID, SECRET, VERSION, TAG, COUNTRY, throttling=0) # No wait time between requests
119+
```
120+
121+
### Working with Models
111122

112-
# No throttling (use with caution)
113-
amazon = AmazonApi(KEY, SECRET, TAG, COUNTRY, throttling=0)
123+
All SDK models are re-exported through `amazon_creatorsapi.models` for convenient access:
124+
125+
```python
126+
from amazon_creatorsapi.models import (
127+
Item,
128+
Condition,
129+
SortBy,
130+
GetItemsResource,
131+
SearchItemsResource,
132+
)
133+
134+
# Use Condition enum for filtering
135+
items = api.get_items(["B01N5IB20Q"], condition=Condition.NEW)
136+
137+
# Use SortBy enum for search ordering
138+
results = api.search_items(keywords="laptop", sort_by=SortBy.PRICE_LOW_TO_HIGH)
139+
140+
# Specify which resources to retrieve
141+
from amazon_creatorsapi.models import GetItemsResource
142+
resources = [GetItemsResource.ITEMINFO_TITLE, GetItemsResource.OFFERS_LISTINGS_PRICE]
143+
items = api.get_items(["B01N5IB20Q"], resources=resources)
114144
```
115145

146+
---
147+
116148
## Documentation
117149

118150
- 📖 [Full Documentation](https://python-amazon-paapi.readthedocs.io/)
@@ -133,7 +165,7 @@ uv sync
133165
uv run pre-commit install
134166
```
135167

136-
3. Copy `.env.template` to `.env` and add your Amazon API credentials for integration tests.
168+
3. Copy `.env.template` to `.env` and add your API credentials for integration tests.
137169

138170
Pre-commit hooks will automatically run Ruff, mypy, and tests before each commit.
139171

amazon_creatorsapi/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"""Amazon Creators API wrapper for Python.
2+
3+
A Python wrapper for the Amazon Creators API.
4+
"""
5+
6+
__author__ = "Sergio Abad"
7+
__all__ = ["AmazonCreatorsApi", "Country", "models"]
8+
9+
from . import models
10+
from .api import AmazonCreatorsApi
11+
from .core import Country

0 commit comments

Comments
 (0)