Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
933f6bb
add async support to creators api
sergioteula Feb 1, 2026
ad4b590
refactor: move async API and its related import logic to a dedicated …
sergioteula Feb 4, 2026
df8c5a0
feat: Add comprehensive unit tests for `AsyncHttpClient` and enhance …
sergioteula Feb 4, 2026
8d7ac24
ci: Add `--extra async` to `uv run` command in the test workflow.
sergioteula Feb 5, 2026
1fc1b2f
fix: Replace `assert` statements with `AuthenticationError` raises fo…
sergioteula Feb 5, 2026
8bade66
chore: unify async installation instruction in error message
sergioteula Feb 8, 2026
160ac76
fix: Prevent throttling race conditions by using an asyncio.Lock in t…
sergioteula Feb 8, 2026
b49f288
refactor: Enhance type safety for generic resource handling and impro…
sergioteula Feb 8, 2026
ec8717e
build: Update project dependencies and configuration in pyproject.toml.
sergioteula Feb 8, 2026
b2de270
feat: Add API version validation to `AsyncAmazonCreatorsApi` initiali…
sergioteula Feb 8, 2026
f6ce9a3
feat: document async/await support and provide usage examples in README.
sergioteula Feb 8, 2026
0180780
feat: Add a 'docs' target to the Makefile for building HTML documenta…
sergioteula Feb 8, 2026
638f4d9
docs: add asynchronous API support with new usage guide and API refer…
sergioteula Feb 8, 2026
7e48111
chore: update changelog and bump project version to 6.1.0.
sergioteula Feb 8, 2026
30601d7
feat: Add `async` extra to `uv run` command in CI pre-commit step.
sergioteula Feb 8, 2026
cb231b9
refactor: Lazily initialize `asyncio.Lock` for Python 3.9 compatibili…
sergioteula Feb 8, 2026
c519d54
ci: Add credential and API version secrets to workflow and enable ver…
sergioteula Feb 8, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ jobs:
API_SECRET: ${{ secrets.API_SECRET }}
AFFILIATE_TAG: ${{ secrets.AFFILIATE_TAG }}
COUNTRY_CODE: ${{ secrets.COUNTRY_CODE }}
CREDENTIAL_ID: ${{ secrets.CREDENTIAL_ID }}
CREDENTIAL_SECRET: ${{ secrets.CREDENTIAL_SECRET }}
API_VERSION: ${{ secrets.API_VERSION }}

steps:
- uses: actions/checkout@v5
Expand Down Expand Up @@ -65,7 +68,7 @@ jobs:

- name: Run all checks
run: |
uv run pre-commit run --all-files
uv run --extra async pre-commit run --all-files --verbose

test:
runs-on: ubuntu-latest
Expand All @@ -91,4 +94,4 @@ jobs:
${{ runner.os }}-uv-py${{ matrix.python-version }}-

- name: Run tests
run: uv run --python "${{ matrix.python-version }}" pytest -rs --no-cov
run: uv run --python "${{ matrix.python-version }}" --extra async pytest -rs --no-cov
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [6.1.0]

### Added

- Full async/await support with new `amazon_creatorsapi.aio` subpackage ([#143](https://github.com/sergioteula/python-amazon-paapi/pull/143))
- `AsyncAmazonCreatorsApi` class for non-blocking API interactions
- Async HTTP client with `httpx` integration for connection pooling
- `AuthenticationError` exception for improved OAuth2 error handling
- Optional `[async]` installation extra: `pip install python-amazon-paapi[async]`
- Comprehensive async test suite with integration tests
- Documentation for async API usage in README and usage guide
- `make docs` command in Makefile for building documentation

### Changed

- GitHub Actions workflow now installs async dependencies for complete test coverage
- Test coverage threshold lowered from 99% to 98% to accommodate async tests
- Additional Ruff linting rules for test files (ARG002, S101, S105, S106, SIM117)

## [6.0.0] - 2026-01-29

### Added
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,8 @@ mypy:

pre-commit:
@uv run pre-commit run -a

docs:
@cd docs && uv run make html

.PHONY: setup test coverage test-all-python-tags lint format mypy pre-commit docs
37 changes: 36 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ A Python wrapper for Amazon's product APIs. This package supports both the legac
## Features

- 🎯 **Simple object-oriented interface** for easy integration
- 🔍 **Product search** by keywords, categories, or browse nodes
- � **Async/await support** for high-performance applications
- �🔍 **Product search** by keywords, categories, or browse nodes
- 📦 **Product details** via ASIN or Amazon URL
- 🔄 **Item variations** support (size, color, etc.)
- 💰 **OffersV2 support** for enhanced pricing and offer details
Expand Down Expand Up @@ -118,6 +119,40 @@ amazon = AmazonCreatorsApi(ID, SECRET, VERSION, TAG, COUNTRY, throttling=4) # M
amazon = AmazonCreatorsApi(ID, SECRET, VERSION, TAG, COUNTRY, throttling=0) # No wait time between requests
```

### Async Support

For async/await applications, use the async version of the API with `httpx`:

```bash
pip install python-amazon-paapi[async] --upgrade
```

The async API provides the same methods as the synchronous version, but they must be called with `await`:

```python
from amazon_creatorsapi.aio import AsyncAmazonCreatorsApi
from amazon_creatorsapi import Country

# Use as async context manager (recommended for connection pooling)
async with AsyncAmazonCreatorsApi(
credential_id="your_credential_id",
credential_secret="your_credential_secret",
version="2.2",
tag="your-affiliate-tag",
country=Country.US,
) as api:
items = await api.get_items(["B01N5IB20Q"])
results = await api.search_items(keywords="laptop")
variations = await api.get_variations("B01N5IB20Q")
nodes = await api.get_browse_nodes(["667049031"])

# Or use without context manager (creates new connection per request)
api = AsyncAmazonCreatorsApi(ID, SECRET, VERSION, TAG, COUNTRY)
items = await api.get_items(["B01N5IB20Q"])
```

> **Note:** All synchronous methods and parameters work identically in async mode. Use `async with` for better performance when making multiple API calls.

### Working with Models

All SDK models are re-exported through `amazon_creatorsapi.models` for convenient access:
Expand Down
14 changes: 14 additions & 0 deletions amazon_creatorsapi/aio/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""Async support for Amazon Creators API."""

try:
import httpx # noqa: F401
except ImportError as exc: # pragma: no cover
msg = (
"httpx is required for async support. "
"Install it with: pip install python-amazon-paapi[async]"
)
raise ImportError(msg) from exc

from amazon_creatorsapi.aio.api import AsyncAmazonCreatorsApi

__all__ = ["AsyncAmazonCreatorsApi"]
Loading