Skip to content

Product Advertising API SearchItemsRequest min_saving_percent not working as expected

0

When I set the min_saving_percent parameter to be an interger 1-99, I am still getting items that do not have a saving percent. The offer.listing[0].saving_basis is None and and offer.listing[0].price.saving is None.

asked 2 years ago253 views

1 Answer
0

`from paapi5_python_sdk.api import ApiClient, SearchItemsResource, SearchItemsRequest from paapi5_python_sdk.models import PartnerType, SearchIndex

def search_items_with_savings(): client = ApiClient() client.configuration.access_key = "YOUR_ACCESS_KEY" client.configuration.secret_key = "YOUR_SECRET_KEY" client.configuration.host = "webservices.amazon.com" client.configuration.region = "us-east-1"

request = SearchItemsRequest(
    partner_tag="YourTag",
    partner_type=PartnerType.ASSOCIATES,
    keywords="example product",
    search_index=SearchIndex.ALL,
    min_saving_percent=50,
    resources=[SearchItemsResource.ITEM_INFO_TITLE, 
               SearchItemsResource.OFFERS_LISTINGS_SAVING_BASIS,
               SearchItemsResource.OFFERS_LISTINGS_PRICE]
)

response = client.search_items(request)

# Check each item for savings data
for item in response.search_result.items:
    if item.offers and item.offers.listings:
        for listing in item.offers.listings:
            print(f"Item: {item.asin}, Saving Basis: {listing.saving_basis}, Price Saving: {listing.price.saving}")
    else:
        print(f"Item {item.asin} has no offer or listing data")

if name == "main": search_items_with_savings()`

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.