Product Ads

Warning

Sponsored Display is not available for Sandbox endpoint

class ad_api.api.sd.ProductAds(account='default', marketplace: Marketplaces = Marketplaces.EU, credentials=None, proxies=None, verify=True, timeout=None, debug=False, access_token=None)

Sponsored Display Product Ads

Documentation: https://advertising.amazon.com/API/docs/en-us/sponsored-display/3-0/openapi#/Product%20ads/

The Sponsored Display API supports creation of reports for campaigns, ad groups, product ads, targets, and asins. Create a ReportRequest object specifying the fields corresponding to performance data metrics to include in the report. See ReportRequest object for more information about the performance data metric fields and their descriptions.

list_product_ads(self, **kwargs) ApiResponse:

Gets a list of product ads.

Gets an array of ProductAd objects for a requested set of Sponsored Display product ads. Note that the ProductAd object is designed for performance, and includes a small set of commonly used fields to reduce size. If the extended set of fields is required, use a product ad operation that returns the ProductAdResponseEx object.

query startIndex:integer | Optional. 0-indexed record offset for the result set. Default value : 0

query count:integer | Optional. Number of records to include in the paged response. Defaults to max page size.

query stateFilter:string | Optional. The returned array is filtered to include only ad groups with state set to one of the values in the specified comma-delimited list. Available values : enabled, paused, archived, enabled, paused, enabled, archived, paused, archived, enabled, paused, archived Default value : enabled, paused, archived.

query adIdFilter:string | Optional. Restricts results to product ads associated with the product ad identifiers specified in the comma-delimited list.

query campaignIdFilter:string | Optional. A comma-delimited list of campaign identifiers.

query adGroupIdFilter:string | Optional. Restricts results to keywords associated with ad groups specified by identifier in the comma-delimited list.

Returns:

ApiResponse

### Example python 1

from ad_api.base import AdvertisingApiException, Marketplaces
from ad_api.api import sponsored_display

try:
    status = 'enabled'
    store = 'my_store'

    result = sponsored_display.ProductAds(account=store,
                                          marketplace=Marketplaces.ES,
                                          debug=True).list_product_ads(
        stateFilter=status
    )
    products_ads = result.payload # <class 'list'>

except AdvertisingApiException as error:
    logging.error(error)

### Example python 2

The default config in the credentials.yml if not passed as kwargs

account=’my_store’,

The default marketplace is Marketplaces.EU if not passed as kwarg ex. Marketplaces.US

marketplace=Marketplaces.US,

Debug info like headers, method and url and raw response will not provided

debug=True

import os
from ad_api.base import AdvertisingApiException
from ad_api.api.sd.product_ads import ProductAds

try:
    status = 'enabled'
    index = 5 # Sets a cursor into the requested set of product ads
    number = 2 # Sets the number of ProductAd objects in the returned array
    result = ProductAds().list_product_ads(
        stateFilter=status
    )

    products_ads = result.payload # <class 'list'>

except AdvertisingApiException as error:
    logging.error(error)
edit_product_ads(self, **kwargs) ApiResponse:

edit_product_ads(self, **kwargs) -> ApiResponse

Updates one or more product ads specified by identifier.

body: | REQUIRED {‘description’: ‘A list of product ad objects with updated values for the state field.}’

adId’: number, {‘description’: ‘The identifier of an existing campaign to update.’}
state’: string, {‘description’: ‘The current resource state.’, ‘Enum’: ‘[ enabled, paused, archived ]’}

Returns:

ApiResponse

### Example body json

An array of ProductAd objects. For each object, specify a product ad identifier and the only mutable field, state. Maximum length of the array is 100 objects.

[
    {
        "state": "enabled",
        "adId": 182575048323550
    }
]

### Example python

import json
from ad_api.api import sponsored_display

try:

    dictionary = \
    [
        {
            "state": "enabled",
            "adId": 182575048323550
        }
    ]

    data = json.dumps(dictionary)

    result = sponsored_display.ProductAds(debug=True).edit_product_ads(
        body=data
    )

    logging.info(result.payload)
    logging.info(json.dumps(response.payload))

except AdvertisingApiException as error:
    logging.error(error)

### Example response.payload <class ‘list’>

[{'code': 'SUCCESS', 'adId': 182575048323550}]

### Example json.dumps(response.payload) <class ‘str’>

[{"code": "SUCCESS", "adId": 182575048323550}]
create_product_ads(self, **kwargs) ApiResponse:

create_product_ads(self, **kwargs) -> ApiResponse

Creates one or more product ads.

body: | REQUIRED {‘description’: ‘An array of ProductAd objects. For each object, specify required fields and their values. Required fields are adGroupId, SKU (for sellers) or ASIN (for vendors), and state’. Maximum length of the array is 100 objects.’}

state’: string, {‘description’: ‘The current resource state.’, ‘Enum’: ‘[ enabled, paused, archived ]’}
adGroupId’: integer($int64), {‘description’: ‘The identifier of the ad group.’}
campaignId’: integer($int64), {‘description’: ‘The identifier of the campaign.’}
asin’: string, {‘description’: ‘The ASIN associated with the product. Defined for vendors only.’}
sku’: string, {‘description’: ‘The SKU associated with the product. Defined for seller accounts only.’}

Returns:

ApiResponse

get_product_ad(self, adId, **kwargs) ApiResponse:

get_product_ad_request(self, adId, **kwargs) -> ApiResponse

Gets a product ad specified by identifier.

path adId:number | Required. A product ad identifier.

Returns:

ApiResponse

delete_product_ad(self, adId, **kwargs) ApiResponse:

delete_product_ad(self, adId, **kwargs) -> ApiResponse

Sets the state of a specified product ad to archived. Note that once the state is set to archived it cannot be changed.

path adId:number | Required. A product ad identifier.

Returns:

ApiResponse

list_product_ads_extended(self, **kwargs) ApiResponse:

list_product_ads_extended_request(self, **kwargs) -> ApiResponse

Gets extended data for a list of product ads filtered by specified criteria.

query startIndex:integer | Optional. 0-indexed record offset for the result set. Default value : 0

query count:integer | Optional. Number of records to include in the paged response. Defaults to max page size.

query stateFilter:string | Optional. The returned array is filtered to include only ad groups with state set to one of the values in the specified comma-delimited list. Available values : enabled, paused, archived, enabled, paused, enabled, archived, paused, archived, enabled, paused, archived Default value : enabled, paused, archived.

query campaignIdFilter:string | Optional. A comma-delimited list of campaign identifiers.

query adGroupIdFilter:string | Optional. Restricts results to keywords associated with ad groups specified by identifier in the comma-delimited list.

query adIdFilter:string | Optional. Restricts results to product ads associated with the product ad identifiers specified in the comma-delimited list.

Returns:

ApiResponse

get_product_ad_extended(self, adId, **kwargs) ApiResponse:

get_product_ad_extended(self, adId, **kwargs) -> ApiResponse

Gets extended data for a product ad specified by identifier.

path adId:number | Required. A product ad identifier.

Returns:

ApiResponse