Skip to content

Commit f6ce9a3

Browse files
committed
feat: document async/await support and provide usage examples in README.
1 parent b2de270 commit f6ce9a3

1 file changed

Lines changed: 36 additions & 1 deletion

File tree

README.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ A Python wrapper for Amazon's product APIs. This package supports both the legac
1313
## Features
1414

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

122+
### Async Support
123+
124+
For async/await applications, use the async version of the API with `httpx`:
125+
126+
```bash
127+
pip install python-amazon-paapi[async] --upgrade
128+
```
129+
130+
The async API provides the same methods as the synchronous version, but they must be called with `await`:
131+
132+
```python
133+
from amazon_creatorsapi.aio import AsyncAmazonCreatorsApi
134+
from amazon_creatorsapi import Country
135+
136+
# Use as async context manager (recommended for connection pooling)
137+
async with AsyncAmazonCreatorsApi(
138+
credential_id="your_credential_id",
139+
credential_secret="your_credential_secret",
140+
version="2.2",
141+
tag="your-affiliate-tag",
142+
country=Country.US,
143+
) as api:
144+
items = await api.get_items(["B01N5IB20Q"])
145+
results = await api.search_items(keywords="laptop")
146+
variations = await api.get_variations("B01N5IB20Q")
147+
nodes = await api.get_browse_nodes(["667049031"])
148+
149+
# Or use without context manager (creates new connection per request)
150+
api = AsyncAmazonCreatorsApi(ID, SECRET, VERSION, TAG, COUNTRY)
151+
items = await api.get_items(["B01N5IB20Q"])
152+
```
153+
154+
> **Note:** All synchronous methods and parameters work identically in async mode. Use `async with` for better performance when making multiple API calls.
155+
121156
### Working with Models
122157

123158
All SDK models are re-exported through `amazon_creatorsapi.models` for convenient access:

0 commit comments

Comments
 (0)