Skip to content

Commit bb17f3a

Browse files
committed
docs: Update and expand usage examples in documentation, including API client variable renaming and new examples for browse nodes and ASIN extraction.
1 parent 00d6dc9 commit bb17f3a

2 files changed

Lines changed: 81 additions & 47 deletions

File tree

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ items = api.get_items(["https://www.amazon.com/dp/B01N5IB20Q"])
5353

5454
## Usage Examples
5555

56+
### Get Multiple Items
57+
58+
```python
59+
items = api.get_items(["B01N5IB20Q", "B01F9G43WU"])
60+
for item in items:
61+
print(item.images.primary.large.url)
62+
```
63+
5664
### Search Products
5765

5866
```python
@@ -82,6 +90,14 @@ for node in nodes:
8290
print(node.display_name)
8391
```
8492

93+
### Get the ASIN from URL
94+
95+
```python
96+
from amazon_creatorsapi import get_asin
97+
98+
asin = get_asin("https://www.amazon.com/dp/B01N5IB20Q")
99+
```
100+
85101
### Using OffersV2 Resources
86102

87103
```python

docs/pages/usage-guide.md

Lines changed: 65 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,75 +2,107 @@
22

33
You can install or upgrade the module with:
44

5-
pip install python-amazon-paapi --upgrade
5+
```bash
6+
pip install python-amazon-paapi --upgrade
7+
```
68

79
# Usage Guide
810

9-
The new `amazon_creatorsapi` module provides access to Amazon's Creators API.
11+
The `amazon_creatorsapi` module provides access to Amazon's Creators API.
1012

1113
> **Note:** The `amazon_paapi` module is deprecated. New projects should use the Creators API.
1214
13-
**Basic usage:**
15+
## Basic Usage
1416

1517
```python
1618
from amazon_creatorsapi import AmazonCreatorsApi, Country
1719

18-
amazon = AmazonCreatorsApi(
19-
credential_id='YOUR_CREDENTIAL_ID',
20-
credential_secret='YOUR_CREDENTIAL_SECRET',
21-
version='2.2',
22-
tag='YOUR_TAG',
23-
country=Country.US
20+
api = AmazonCreatorsApi(
21+
credential_id="your_credential_id",
22+
credential_secret="your_credential_secret",
23+
version="2.2",
24+
tag="your-affiliate-tag",
25+
country=Country.US,
2426
)
2527

26-
item = amazon.get_items('B01N5IB20Q')[0]
27-
print(item.item_info.title.display_value) # Item title
28+
# Get product information by ASIN
29+
items = api.get_items(["B01N5IB20Q"])
30+
print(items[0].item_info.title.display_value)
31+
32+
# Or use Amazon URLs directly
33+
items = api.get_items(["https://www.amazon.com/dp/B01N5IB20Q"])
2834
```
2935

30-
**Get multiple items information:**
36+
## Get Multiple Items
3137

3238
```python
33-
items = amazon.get_items(['B01N5IB20Q', 'B01F9G43WU'])
39+
items = api.get_items(["B01N5IB20Q", "B01F9G43WU"])
3440
for item in items:
35-
print(item.images.primary.large.url) # Primary image url
41+
print(item.images.primary.large.url)
3642
```
3743

38-
**Search items:**
44+
## Search Products
3945

4046
```python
41-
search_result = amazon.search_items(keywords='nintendo')
42-
for item in search_result.items:
43-
print(item.asin) # Item ASIN
47+
results = api.search_items(keywords="nintendo switch")
48+
for item in results.items:
49+
print(item.item_info.title.display_value)
4450
```
4551

46-
**Get item variations:**
52+
## Get Product Variations
4753

4854
```python
49-
variations = amazon.get_variations('B01N5IB20Q')
55+
# Using ASIN
56+
variations = api.get_variations("B01N5IB20Q")
57+
58+
# Or using Amazon URL
59+
variations = api.get_variations("https://www.amazon.com/dp/B01N5IB20Q")
60+
5061
for item in variations.items:
51-
print(item.detail_page_url) # Affiliate url
62+
print(item.detail_page_url)
5263
```
5364

54-
**Get the ASIN from URL:**
65+
## Get Browse Node Information
5566

5667
```python
57-
from amazon_creatorsapi.core import get_asin
68+
nodes = api.get_browse_nodes(["667049031"])
69+
for node in nodes:
70+
print(node.display_name)
71+
```
72+
73+
## Get the ASIN from URL
5874

59-
asin = get_asin('https://www.amazon.com/dp/B01N5IB20Q')
75+
```python
76+
from amazon_creatorsapi import get_asin
77+
78+
asin = get_asin("https://www.amazon.com/dp/B01N5IB20Q")
6079
```
6180

62-
**Throttling:**
81+
## Using OffersV2 Resources
82+
83+
OffersV2 provides enhanced pricing and offer details. All resources are included by default:
84+
85+
```python
86+
items = api.get_items(["B01N5IB20Q"])
87+
item = items[0]
88+
if item.offers_v2 and item.offers_v2.listings:
89+
listing = item.offers_v2.listings[0]
90+
print(listing.price.money.amount)
91+
print(listing.merchant_info.name)
92+
```
93+
94+
## Throttling
6395

6496
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.
6597

6698
```python
67-
amazon = AmazonCreatorsApi(ID, SECRET, VERSION, TAG, COUNTRY, throttling=4) # Makes 1 request every 4 seconds
68-
amazon = AmazonCreatorsApi(ID, SECRET, VERSION, TAG, COUNTRY, throttling=0) # No wait time between requests
99+
api = AmazonCreatorsApi(ID, SECRET, VERSION, TAG, COUNTRY, throttling=4) # Makes 1 request every 4 seconds
100+
api = AmazonCreatorsApi(ID, SECRET, VERSION, TAG, COUNTRY, throttling=0) # No wait time between requests
69101
```
70102

71-
**Working with Models:**
103+
## Working with Models
72104

73-
All SDK models are available through the `models` module for convenient access:
105+
All SDK models are re-exported through `amazon_creatorsapi.models` for convenient access:
74106

75107
```python
76108
from amazon_creatorsapi.models import (
@@ -82,27 +114,13 @@ from amazon_creatorsapi.models import (
82114
)
83115

84116
# Use Condition enum for filtering
85-
items = amazon.get_items(['B01N5IB20Q'], condition=Condition.NEW)
117+
items = api.get_items(["B01N5IB20Q"], condition=Condition.NEW)
86118

87119
# Use SortBy enum for search ordering
88-
results = amazon.search_items(keywords='laptop', sort_by=SortBy.PRICE_LOW_TO_HIGH)
120+
results = api.search_items(keywords="laptop", sort_by=SortBy.PRICE_LOW_TO_HIGH)
89121

90122
# Specify which resources to retrieve
123+
from amazon_creatorsapi.models import GetItemsResource
91124
resources = [GetItemsResource.ITEMINFO_TITLE, GetItemsResource.OFFERS_LISTINGS_PRICE]
92-
items = amazon.get_items(['B01N5IB20Q'], resources=resources)
93-
```
94-
95-
**Using OffersV2 resources:**
96-
97-
OffersV2 provides enhanced pricing and offer details. All resources are included by default, so OffersV2 data is available without any additional configuration:
98-
99-
```python
100-
items = amazon.get_items('B01N5IB20Q')
101-
102-
# Access OffersV2 data
103-
item = items[0]
104-
if item.offers_v2 and item.offers_v2.listings:
105-
listing = item.offers_v2.listings[0]
106-
print(listing.price.money.amount) # Price amount
107-
print(listing.merchant_info.name) # Merchant name
125+
items = api.get_items(["B01N5IB20Q"], resources=resources)
108126
```

0 commit comments

Comments
 (0)