python-amazon-ad-api 0.9.6__py3-none-any.whl → 0.9.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ad_api/api/sp/campaigns.py +527 -353
- ad_api/api/sp/campaigns_v3.py +1 -0
- ad_api/version.py +1 -1
- {python_amazon_ad_api-0.9.6.dist-info → python_amazon_ad_api-0.9.8.dist-info}/METADATA +36 -4
- {python_amazon_ad_api-0.9.6.dist-info → python_amazon_ad_api-0.9.8.dist-info}/RECORD +8 -8
- {python_amazon_ad_api-0.9.6.dist-info → python_amazon_ad_api-0.9.8.dist-info}/WHEEL +0 -0
- {python_amazon_ad_api-0.9.6.dist-info → python_amazon_ad_api-0.9.8.dist-info}/licenses/LICENSE +0 -0
- {python_amazon_ad_api-0.9.6.dist-info → python_amazon_ad_api-0.9.8.dist-info}/top_level.txt +0 -0
ad_api/api/sp/campaigns.py
CHANGED
|
@@ -10,379 +10,553 @@ class Campaigns(Client):
|
|
|
10
10
|
|
|
11
11
|
"""
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
@
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
13
|
+
# DEPRECATED v2 — superseded by v1 endpoints. Kept commented for reference.
|
|
14
|
+
# @sp_endpoint('/v2/sp/campaigns', method='PUT')
|
|
15
|
+
# @Utils.deprecated
|
|
16
|
+
# def edit_single_campaign_assistant(
|
|
17
|
+
# self,
|
|
18
|
+
# campaign_id: int,
|
|
19
|
+
# portfolio_id: int = None,
|
|
20
|
+
# campaign_name: str = None,
|
|
21
|
+
# po_number: str = None,
|
|
22
|
+
# account_manager: str = None,
|
|
23
|
+
# campaign_status: str = None,
|
|
24
|
+
# daily_budget: int = None,
|
|
25
|
+
# start_date: str = None,
|
|
26
|
+
# end_date: str = None,
|
|
27
|
+
# premium_bid_adjustment: bool = None,
|
|
28
|
+
# strategy: str = None,
|
|
29
|
+
# predicate: str or tuple = None,
|
|
30
|
+
# percentage: str or tuple = None,
|
|
31
|
+
# **kwargs,
|
|
32
|
+
# ) -> ApiResponse:
|
|
33
|
+
# r"""
|
|
34
|
+
# edit_single_campaign_assistant(campaign_id: int, portfolio_id: int = None, campaign_name: str, po_number: str = None, account_manager: str = None, campaign_status: str = None, daily_budget: int, start_date: str, end_date: str = None, premium_bid_adjustment: bool = None, strategy:str = None, predicate:str or tuple = None, percentage:int or tuple = None, **kwargs) -> ApiResponse
|
|
35
|
+
#
|
|
36
|
+
# Edit one campaigns and create the body based on the params provided, at least one of the optional params need to be set or a INVALID_ARGUMENT code is thorwn
|
|
37
|
+
#
|
|
38
|
+
# Kwargs:
|
|
39
|
+
# | **campaign_id** (number): [required] The identifier of an existing campaign to update.
|
|
40
|
+
# | **portfolio_id** (number): [optional] The identifier of an existing portfolio to which the campaign is associated
|
|
41
|
+
# | **campaign_name** (string): [optional] A name for the campaign
|
|
42
|
+
# | **po_number** (string): [optional] 'A list of advertiser-specified custom identifiers for the campaign. Each customer identifier is a key-value pair. You can specify a maximum of 50 identifiers
|
|
43
|
+
# | **account_manager** (string): [optional] A list of advertiser-specified custom identifiers for the campaign. Each customer identifier is a key-value pair. You can specify a maximum of 50 identifiers
|
|
44
|
+
# | **campaign_status**': (string): [optional] The current resource state Values: enabled, paused, archived. Default: enabled
|
|
45
|
+
# | **daily_budget** (float): [optional] A daily budget for the campaign
|
|
46
|
+
# | **start_date** (string): [optional] A starting date for the campaign to go live. The format of the date is YYYYMMDD
|
|
47
|
+
# | **end_date** (string): [optional] An ending date for the campaign to stop running. The format of the date is YYYYMMDD
|
|
48
|
+
# | **premium_bid_adjustment**' (boolean): [optional] If set to true, Amazon increases the default bid for ads that are eligible to appear in this placement. See developer notes for more information. Tip: When Campaign has been adopted to enhanced bidding premiumBidAdjustment can not be set
|
|
49
|
+
# | **strategy** (string): [optional] The bidding strategy. 'Values': legacyForSales (Dynamic bids - down only), autoForSales (Dynamic bids - up and down), manual (Fixed bid)
|
|
50
|
+
# | **predicate** (string or tuple(str)): [optional] You can enable controls to adjust your bid based on the placement location. Specify a location where you want to use bid controls. The percentage value set is the percentage of the original bid for which you want to have your bid adjustment increased. For example, a 50% adjustment on a $1.00 bid would increase the bid to $1.50 for the opportunity to win a specified placement. 'Values': placementTop (str), placementProductPage (str), ("placementTop", "placementProductPage") (tuple)
|
|
51
|
+
# | **percentage** (float or tuple(float)): [optional] The bid adjustment percentage value. Example: 15 (float), (15, 25) (tuple)
|
|
52
|
+
#
|
|
53
|
+
# Returns:
|
|
54
|
+
#
|
|
55
|
+
# ApiResponse
|
|
56
|
+
#
|
|
57
|
+
# """
|
|
58
|
+
#
|
|
59
|
+
# optional = {}
|
|
60
|
+
#
|
|
61
|
+
# if portfolio_id is not None:
|
|
62
|
+
# optional.update({'portfolioId': portfolio_id})
|
|
63
|
+
#
|
|
64
|
+
# if campaign_name is not None:
|
|
65
|
+
# optional.update({'name': campaign_name})
|
|
66
|
+
#
|
|
67
|
+
# if po_number is not None and account_manager is not None:
|
|
68
|
+
# optional.update({"tags": {'PONumber': po_number, 'accountManager': account_manager}})
|
|
69
|
+
#
|
|
70
|
+
# if campaign_status is not None:
|
|
71
|
+
# optional.update({'state': campaign_status})
|
|
72
|
+
#
|
|
73
|
+
# if daily_budget is not None:
|
|
74
|
+
# optional.update({'dailyBudget': daily_budget})
|
|
75
|
+
#
|
|
76
|
+
# if start_date is not None:
|
|
77
|
+
# optional.update({'startDate': start_date})
|
|
78
|
+
#
|
|
79
|
+
# if end_date is not None:
|
|
80
|
+
# optional.update({'endDate': end_date})
|
|
81
|
+
#
|
|
82
|
+
# if premium_bid_adjustment is not None:
|
|
83
|
+
# optional.update({'premiumBidAdjustment': premium_bid_adjustment})
|
|
84
|
+
#
|
|
85
|
+
# if strategy is not None and predicate is None and percentage is None:
|
|
86
|
+
# optional.update({'bidding': {'strategy': strategy, 'adjustments': []}})
|
|
87
|
+
#
|
|
88
|
+
# if strategy is not None and predicate is not None and percentage is not None:
|
|
89
|
+
# if isinstance(predicate, str):
|
|
90
|
+
# optional.update(
|
|
91
|
+
# {
|
|
92
|
+
# 'bidding': {
|
|
93
|
+
# 'strategy': strategy,
|
|
94
|
+
# 'adjustments': [{'predicate': predicate, 'percentage': percentage}],
|
|
95
|
+
# }
|
|
96
|
+
# }
|
|
97
|
+
# )
|
|
98
|
+
#
|
|
99
|
+
# if isinstance(predicate, tuple) and len(predicate) == 2 and len(percentage) == 2:
|
|
100
|
+
# options = []
|
|
101
|
+
# for i in range(len(predicate)):
|
|
102
|
+
# option = {"predicate": predicate[i], "percentage": percentage[i]}
|
|
103
|
+
# options.append(option)
|
|
104
|
+
#
|
|
105
|
+
# bidding = {'strategy': strategy, 'adjustments': options}
|
|
106
|
+
#
|
|
107
|
+
# dictionary = {}
|
|
108
|
+
# dictionary["bidding"] = bidding
|
|
109
|
+
#
|
|
110
|
+
# optional.update(dictionary)
|
|
111
|
+
#
|
|
112
|
+
# required = {
|
|
113
|
+
# 'campaignId': campaign_id,
|
|
114
|
+
# }
|
|
115
|
+
#
|
|
116
|
+
# if not optional:
|
|
117
|
+
# description = 'No changes submitted for entity %s' % campaign_id
|
|
118
|
+
# obj = [{'code': 'INVALID_ARGUMENT', 'description': description}]
|
|
119
|
+
# return ApiResponse(obj)
|
|
120
|
+
# else:
|
|
121
|
+
# required.update(optional)
|
|
122
|
+
# data_str = json.dumps([required])
|
|
123
|
+
# return self._request(kwargs.pop('path'), data=data_str, params=kwargs)
|
|
124
|
+
#
|
|
125
|
+
# DEPRECATED v2 — superseded by v1 endpoints. Kept commented for reference.
|
|
126
|
+
# @sp_endpoint('/v2/sp/campaigns', method='POST')
|
|
127
|
+
# @Utils.deprecated
|
|
128
|
+
# def create_single_campaign_assistant(
|
|
129
|
+
# self,
|
|
130
|
+
# campaign_name: str,
|
|
131
|
+
# targeting_type: str,
|
|
132
|
+
# daily_budget: int,
|
|
133
|
+
# start_date: str,
|
|
134
|
+
# end_date: str = None,
|
|
135
|
+
# campaign_status: str = "enabled",
|
|
136
|
+
# portfolio_id: int = None,
|
|
137
|
+
# po_number: str = None,
|
|
138
|
+
# account_manager: str = None,
|
|
139
|
+
# premium_bid_adjustment: bool = None,
|
|
140
|
+
# strategy: str = None,
|
|
141
|
+
# predicate: str or tuple = None,
|
|
142
|
+
# percentage: int or tuple = None,
|
|
143
|
+
# **kwargs,
|
|
144
|
+
# ) -> ApiResponse:
|
|
145
|
+
# r"""
|
|
146
|
+
# create_single_campaign_assistant(campaign_name: str,targeting_type: str, daily_budget: int, start_date: str, end_date: str = None, campaign_status: str = "enabled", portfolio_id: int = None, po_number: str = None, account_manager: str = None, premium_bid_adjustment: bool = False, strategy:str = None, predicate:str = None, percentage:int = None, **kwargs) -> ApiResponse
|
|
147
|
+
#
|
|
148
|
+
# Creates one campaigns and create the body based on the params provided
|
|
149
|
+
#
|
|
150
|
+
# Kwargs:
|
|
151
|
+
#
|
|
152
|
+
# | **campaign_name** (string): [required] A name for the campaign
|
|
153
|
+
# | **campaign_type** (string): [fixed] The advertising product managed by this campaign. Value: sponsoredProducts
|
|
154
|
+
# | **targeting_type** (string): [required] The type of targeting for the campaign. Values: manual, auto
|
|
155
|
+
# | **daily_budget** (float): [required] A daily budget for the campaign
|
|
156
|
+
# | **start_date** (string): [required] A starting date for the campaign to go live. The format of the date is YYYYMMDD
|
|
157
|
+
# | **end_date** (string): [optional] An ending date for the campaign to stop running. The format of the date is YYYYMMDD
|
|
158
|
+
# | **campaign_status**': (string): [optional] The current resource state Values: enabled, paused, archived. Default: enabled
|
|
159
|
+
# | **portfolio_id** (number): [optional] The identifier of an existing portfolio to which the campaign is associated
|
|
160
|
+
# | **po_number** (string): [optional] 'A list of advertiser-specified custom identifiers for the campaign. Each customer identifier is a key-value pair. You can specify a maximum of 50 identifiers
|
|
161
|
+
# | **account_manager** (string): [optional] A list of advertiser-specified custom identifiers for the campaign. Each customer identifier is a key-value pair. You can specify a maximum of 50 identifiers
|
|
162
|
+
# | **premium_bid_adjustment**' (boolean) If set to true, Amazon increases the default bid for ads that are eligible to appear in this placement. See developer notes for more information.
|
|
163
|
+
# | **strategy** (string): [optional] The bidding strategy. 'Values': legacyForSales (Dynamic bids - down only), autoForSales (Dynamic bids - up and down), manual (Fixed bid)
|
|
164
|
+
# | **predicate** (string): [optional] You can enable controls to adjust your bid based on the placement location. Specify a location where you want to use bid controls. The percentage value set is the percentage of the original bid for which you want to have your bid adjustment increased. For example, a 50% adjustment on a $1.00 bid would increase the bid to $1.50 for the opportunity to win a specified placement. 'Values': placementTop, placementProductPage
|
|
165
|
+
# | **percentage** (float): [optional] The bid adjustment percentage value.
|
|
166
|
+
#
|
|
167
|
+
# Returns:
|
|
168
|
+
#
|
|
169
|
+
# ApiResponse
|
|
170
|
+
#
|
|
171
|
+
# """
|
|
172
|
+
#
|
|
173
|
+
# optional = {}
|
|
174
|
+
#
|
|
175
|
+
# if portfolio_id is not None:
|
|
176
|
+
# optional.update({'portfolioId': portfolio_id})
|
|
177
|
+
#
|
|
178
|
+
# if po_number is not None and account_manager is not None:
|
|
179
|
+
# optional.update({"tags": {'PONumber': po_number, 'accountManager': account_manager}})
|
|
180
|
+
#
|
|
181
|
+
# if end_date is not None:
|
|
182
|
+
# optional.update({'endDate': end_date})
|
|
183
|
+
#
|
|
184
|
+
# if premium_bid_adjustment is not None:
|
|
185
|
+
# optional.update({'premiumBidAdjustment': premium_bid_adjustment})
|
|
186
|
+
#
|
|
187
|
+
# if strategy is not None and predicate is not None and percentage is not None:
|
|
188
|
+
# if isinstance(predicate, str):
|
|
189
|
+
# optional.update(
|
|
190
|
+
# {
|
|
191
|
+
# 'bidding': {
|
|
192
|
+
# 'strategy': strategy,
|
|
193
|
+
# 'adjustments': [{'predicate': predicate, 'percentage': percentage}],
|
|
194
|
+
# }
|
|
195
|
+
# }
|
|
196
|
+
# )
|
|
197
|
+
#
|
|
198
|
+
# if isinstance(predicate, tuple) and len(predicate) == 2 and len(percentage) == 2:
|
|
199
|
+
# options = []
|
|
200
|
+
# for i in range(len(predicate)):
|
|
201
|
+
# option = {"predicate": predicate[i], "percentage": percentage[i]}
|
|
202
|
+
# options.append(option)
|
|
203
|
+
#
|
|
204
|
+
# bidding = {'strategy': strategy, 'adjustments': options}
|
|
205
|
+
#
|
|
206
|
+
# dictionary = {}
|
|
207
|
+
# dictionary["bidding"] = bidding
|
|
208
|
+
#
|
|
209
|
+
# optional.update(dictionary)
|
|
210
|
+
#
|
|
211
|
+
# required = {
|
|
212
|
+
# 'name': campaign_name,
|
|
213
|
+
# 'campaignType': 'sponsoredProducts',
|
|
214
|
+
# 'targetingType': targeting_type,
|
|
215
|
+
# 'state': campaign_status,
|
|
216
|
+
# 'dailyBudget': daily_budget,
|
|
217
|
+
# 'startDate': start_date,
|
|
218
|
+
# }
|
|
219
|
+
#
|
|
220
|
+
# if optional:
|
|
221
|
+
# required.update(optional)
|
|
222
|
+
#
|
|
223
|
+
# data_str = json.dumps([required])
|
|
224
|
+
# return self._request(kwargs.pop('path'), data=data_str, params=kwargs)
|
|
225
|
+
#
|
|
226
|
+
# DEPRECATED v2 — superseded by v1 endpoints. Kept commented for reference.
|
|
227
|
+
# @sp_endpoint('/v2/sp/campaigns', method='POST')
|
|
228
|
+
# @Utils.deprecated
|
|
229
|
+
# def create_campaigns(self, **kwargs) -> ApiResponse:
|
|
230
|
+
# r"""
|
|
231
|
+
# create_campaigns(body: (dict, str, list)) -> ApiResponse
|
|
232
|
+
#
|
|
233
|
+
# Creates one or more campaigns.
|
|
234
|
+
#
|
|
235
|
+
# body: | REQUIRED {'description': 'An array of campaigns.}'
|
|
236
|
+
#
|
|
237
|
+
# | '**portfolioId**': *number*, {'description': 'The identifier of an existing portfolio to which the campaign is associated'}
|
|
238
|
+
# | '**name**': *string*, {'description': 'A name for the campaign'}
|
|
239
|
+
# | '**tags**': *string*, {'description': 'A list of advertiser-specified custom identifiers for the campaign. Each customer identifier is a key-value pair. You can specify a maximum of 50 identifiers.'}
|
|
240
|
+
# | '**campaignType**': *string*, {'description': 'The advertising product managed by this campaign', 'Enum': '[ sponsoredProducts ]'}
|
|
241
|
+
# | '**targetingType**': *string*, {'description': 'The type of targeting for the campaign.', 'Enum': '[ manual, auto ]'}
|
|
242
|
+
# | '**state**': *string*, {'description': 'The current resource state.', 'Enum': '[ enabled, paused, archived ]'}
|
|
243
|
+
# | '**dailyBudget**': *number($float)*, {'description': 'A daily budget for the campaign.'}
|
|
244
|
+
# | '**startDate**': *string*, {'description': 'A starting date for the campaign to go live. The format of the date is YYYYMMDD.'}
|
|
245
|
+
# | '**endDate**': *string* nullable: true, {'description': 'An ending date for the campaign to stop running. The format of the date is YYYYMMDD.'}
|
|
246
|
+
# | '**premiumBidAdjustment**': *boolean*, {'description': 'If set to true, Amazon increases the default bid for ads that are eligible to appear in this placement. See developer notes for more information.'}
|
|
247
|
+
# | '**bidding**': *Bidding*, {'strategy': 'string', 'Enum': '[ legacyForSales, autoForSales, manual ]', 'adjustments': '{...}'}
|
|
248
|
+
#
|
|
249
|
+
# Returns:
|
|
250
|
+
#
|
|
251
|
+
# ApiResponse
|
|
252
|
+
#
|
|
253
|
+
# """
|
|
254
|
+
# body = Utils.convert_body(kwargs.pop('body'))
|
|
255
|
+
# return self._request(kwargs.pop('path'), data=body, params=kwargs)
|
|
256
|
+
#
|
|
257
|
+
# DEPRECATED v2 — superseded by v1 endpoints. Kept commented for reference.
|
|
258
|
+
# @sp_endpoint('/v2/sp/campaigns', method='PUT')
|
|
259
|
+
# @Utils.deprecated
|
|
260
|
+
# def edit_campaigns(self, **kwargs) -> ApiResponse:
|
|
261
|
+
# r"""
|
|
262
|
+
# edit_campaigns(body: (dict, str, list)) -> ApiResponse
|
|
263
|
+
#
|
|
264
|
+
# Updates one or more campaigns.
|
|
265
|
+
#
|
|
266
|
+
# body: | REQUIRED {'description': 'An array of campaigns.}'
|
|
267
|
+
#
|
|
268
|
+
# | '**campaignId**': *number*, {'description': 'The identifier of an existing campaign to update.'}
|
|
269
|
+
# | '**portfolioId**': *number*, {'description': 'The identifier of an existing portfolio to which the campaign is associated'}
|
|
270
|
+
# | '**name**': *string*, {'description': 'The name for the campaign'}
|
|
271
|
+
# | '**tags**': *CampaignTags*, {'description': 'A list of advertiser-specified custom identifiers for the campaign. Each customer identifier is a key-value pair. You can specify a maximum of 50 identifiers.'}
|
|
272
|
+
# | '**state**': *string*, {'description': 'The current resource state.', 'Enum': '[ enabled, paused, archived ]'}
|
|
273
|
+
# | '**dailyBudget**': *number($float)*, {'description': 'The daily budget for the campaign.'}
|
|
274
|
+
# | '**startDate**': *string*, {'description': 'The starting date for the campaign to go live. The format of the date is YYYYMMDD.'}
|
|
275
|
+
# | '**endDate**': *string* nullable: true, {'description': 'The ending date for the campaign to stop running. The format of the date is YYYYMMDD.'}
|
|
276
|
+
# | '**premiumBidAdjustment**': *boolean*, {'description': 'If set to true, Amazon increases the default bid for ads that are eligible to appear in this placement. See developer notes for more information.'}
|
|
277
|
+
# | '**bidding**': *Bidding*, {'strategy': 'string', 'Enum': '[ legacyForSales, autoForSales, manual ]', 'adjustments': '{...}'}
|
|
278
|
+
#
|
|
279
|
+
# Returns:
|
|
280
|
+
#
|
|
281
|
+
# ApiResponse
|
|
282
|
+
#
|
|
283
|
+
# """
|
|
284
|
+
# body = Utils.convert_body(kwargs.pop('body'))
|
|
285
|
+
# return self._request(kwargs.pop('path'), data=body, params=kwargs)
|
|
286
|
+
#
|
|
287
|
+
# DEPRECATED v2 — superseded by v1 endpoints. Kept commented for reference.
|
|
288
|
+
# @sp_endpoint('/v2/sp/campaigns', method='GET')
|
|
289
|
+
# @Utils.deprecated
|
|
290
|
+
# def list_campaigns(self, **kwargs) -> ApiResponse:
|
|
291
|
+
# r"""
|
|
292
|
+
# list_campaigns(**kwargs) -> ApiResponse
|
|
293
|
+
#
|
|
294
|
+
# Gets an array of campaigns.
|
|
295
|
+
#
|
|
296
|
+
# query **startIndex**:*integer* | Optional. 0-indexed record offset for the result set. Default value : 0
|
|
297
|
+
#
|
|
298
|
+
# query **count**:*integer* | Optional. Number of records to include in the paged response. Defaults to max page size.
|
|
299
|
+
#
|
|
300
|
+
# 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.
|
|
301
|
+
#
|
|
302
|
+
# query **name**:*string* | Optional. Restricts results to campaigns with the specified name.
|
|
303
|
+
#
|
|
304
|
+
# query **portfolioIdFilter**:*string* | Optional. A comma-delimited list of portfolio identifiers.
|
|
305
|
+
#
|
|
306
|
+
# query **campaignIdFilter**:*string* | Optional. A comma-delimited list of campaign identifiers.
|
|
307
|
+
#
|
|
308
|
+
# Returns:
|
|
309
|
+
#
|
|
310
|
+
# ApiResponse
|
|
311
|
+
#
|
|
312
|
+
# """
|
|
313
|
+
# return self._request(kwargs.pop('path'), params=kwargs)
|
|
314
|
+
#
|
|
315
|
+
# DEPRECATED v2 — superseded by v1 endpoints. Kept commented for reference.
|
|
316
|
+
# @sp_endpoint('/v2/sp/campaigns/{}', method='GET')
|
|
317
|
+
# @Utils.deprecated
|
|
318
|
+
# def get_campaign(self, campaignId, **kwargs) -> ApiResponse:
|
|
319
|
+
# r"""
|
|
320
|
+
#
|
|
321
|
+
# get_campaign(campaignId: int) -> ApiResponse
|
|
322
|
+
#
|
|
323
|
+
# Gets a campaign specified by identifier.
|
|
324
|
+
#
|
|
325
|
+
# path **campaignId**:*number* | Required. The identifier of an existing campaign.
|
|
326
|
+
#
|
|
327
|
+
# Returns:
|
|
328
|
+
#
|
|
329
|
+
# ApiResponse
|
|
330
|
+
#
|
|
331
|
+
# """
|
|
332
|
+
# return self._request(fill_query_params(kwargs.pop('path'), campaignId), params=kwargs)
|
|
333
|
+
#
|
|
334
|
+
# DEPRECATED v2 — superseded by v1 endpoints. Kept commented for reference.
|
|
335
|
+
# @sp_endpoint('/v2/sp/campaigns/{}', method='DELETE')
|
|
336
|
+
# @Utils.deprecated
|
|
337
|
+
# def delete_campaign(self, campaignId, **kwargs) -> ApiResponse:
|
|
338
|
+
# r"""
|
|
339
|
+
#
|
|
340
|
+
# delete_campaign(campaignId: int) -> ApiResponse
|
|
341
|
+
#
|
|
342
|
+
# Sets the campaign status to archived. Archived entities cannot be made active again. See developer notes for more information.
|
|
343
|
+
#
|
|
344
|
+
# path **campaignId**:*number* | Required. The identifier of an existing campaign.
|
|
345
|
+
#
|
|
346
|
+
# Returns:
|
|
347
|
+
#
|
|
348
|
+
# ApiResponse
|
|
349
|
+
#
|
|
350
|
+
# """
|
|
351
|
+
# return self._request(fill_query_params(kwargs.pop('path'), campaignId), params=kwargs)
|
|
352
|
+
#
|
|
353
|
+
# DEPRECATED v2 — superseded by v1 endpoints. Kept commented for reference.
|
|
354
|
+
# @sp_endpoint('/v2/sp/campaigns/extended', method='GET')
|
|
355
|
+
# @Utils.deprecated
|
|
356
|
+
# def list_campaigns_extended(self, **kwargs) -> ApiResponse:
|
|
357
|
+
# r"""
|
|
358
|
+
# list_campaigns_extended(**kwargs) -> ApiResponse
|
|
359
|
+
#
|
|
360
|
+
# Gets an array of campaigns with extended data fields.
|
|
361
|
+
#
|
|
362
|
+
# query **startIndex**:*integer* | Optional. 0-indexed record offset for the result set. Default value : 0
|
|
363
|
+
#
|
|
364
|
+
# query **count**:*integer* | Optional. Number of records to include in the paged response. Defaults to max page size.
|
|
365
|
+
#
|
|
366
|
+
# 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.
|
|
367
|
+
#
|
|
368
|
+
# query **name**:*string* | Optional. Restricts results to campaigns with the specified name.
|
|
369
|
+
#
|
|
370
|
+
# query **portfolioIdFilter**:*string* | Optional. A comma-delimited list of portfolio identifiers.
|
|
371
|
+
#
|
|
372
|
+
# query **campaignIdFilter**:*string* | Optional. A comma-delimited list of campaign identifiers.
|
|
373
|
+
#
|
|
374
|
+
# Returns:
|
|
375
|
+
#
|
|
376
|
+
# ApiResponse
|
|
377
|
+
#
|
|
378
|
+
# """
|
|
379
|
+
# return self._request(kwargs.pop('path'), params=kwargs)
|
|
380
|
+
#
|
|
381
|
+
# DEPRECATED v2 — superseded by v1 endpoints. Kept commented for reference.
|
|
382
|
+
# @sp_endpoint('/v2/sp/campaigns/extended/{}', method='GET')
|
|
383
|
+
# @Utils.deprecated
|
|
384
|
+
# def get_campaign_extended(self, campaignId, **kwargs) -> ApiResponse:
|
|
385
|
+
# r"""
|
|
386
|
+
# get_campaign_extended(campaignId: int) -> ApiResponse
|
|
387
|
+
#
|
|
388
|
+
# Gets an array of campaigns with extended data fields.
|
|
389
|
+
#
|
|
390
|
+
# path **campaignId**:*number* | Required. The identifier of an existing campaign.
|
|
391
|
+
#
|
|
392
|
+
# Returns:
|
|
393
|
+
#
|
|
394
|
+
# ApiResponse
|
|
395
|
+
#
|
|
396
|
+
# """
|
|
397
|
+
# return self._request(fill_query_params(kwargs.pop('path'), campaignId), params=kwargs)
|
|
398
|
+
#
|
|
399
|
+
@sp_endpoint('/adsApi/v1/query/campaigns', method='POST')
|
|
400
|
+
def query_campaigns(self, **kwargs) -> ApiResponse:
|
|
32
401
|
r"""
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
| **
|
|
39
|
-
|
|
40
|
-
| **
|
|
41
|
-
|
|
42
|
-
| **
|
|
43
|
-
|
|
44
|
-
| **
|
|
45
|
-
|
|
46
|
-
| **
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
| **
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if campaign_name is not None:
|
|
64
|
-
optional.update({'name': campaign_name})
|
|
65
|
-
|
|
66
|
-
if po_number is not None and account_manager is not None:
|
|
67
|
-
optional.update({"tags": {'PONumber': po_number, 'accountManager': account_manager}})
|
|
68
|
-
|
|
69
|
-
if campaign_status is not None:
|
|
70
|
-
optional.update({'state': campaign_status})
|
|
71
|
-
|
|
72
|
-
if daily_budget is not None:
|
|
73
|
-
optional.update({'dailyBudget': daily_budget})
|
|
74
|
-
|
|
75
|
-
if start_date is not None:
|
|
76
|
-
optional.update({'startDate': start_date})
|
|
77
|
-
|
|
78
|
-
if end_date is not None:
|
|
79
|
-
optional.update({'endDate': end_date})
|
|
80
|
-
|
|
81
|
-
if premium_bid_adjustment is not None:
|
|
82
|
-
optional.update({'premiumBidAdjustment': premium_bid_adjustment})
|
|
83
|
-
|
|
84
|
-
if strategy is not None and predicate is None and percentage is None:
|
|
85
|
-
optional.update({'bidding': {'strategy': strategy, 'adjustments': []}})
|
|
86
|
-
|
|
87
|
-
if strategy is not None and predicate is not None and percentage is not None:
|
|
88
|
-
if isinstance(predicate, str):
|
|
89
|
-
optional.update(
|
|
90
|
-
{
|
|
91
|
-
'bidding': {
|
|
92
|
-
'strategy': strategy,
|
|
93
|
-
'adjustments': [{'predicate': predicate, 'percentage': percentage}],
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
if isinstance(predicate, tuple) and len(predicate) == 2 and len(percentage) == 2:
|
|
99
|
-
options = []
|
|
100
|
-
for i in range(len(predicate)):
|
|
101
|
-
option = {"predicate": predicate[i], "percentage": percentage[i]}
|
|
102
|
-
options.append(option)
|
|
103
|
-
|
|
104
|
-
bidding = {'strategy': strategy, 'adjustments': options}
|
|
105
|
-
|
|
106
|
-
dictionary = {}
|
|
107
|
-
dictionary["bidding"] = bidding
|
|
108
|
-
|
|
109
|
-
optional.update(dictionary)
|
|
110
|
-
|
|
111
|
-
required = {
|
|
112
|
-
'campaignId': campaign_id,
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
if not optional:
|
|
116
|
-
description = 'No changes submitted for entity %s' % campaign_id
|
|
117
|
-
obj = [{'code': 'INVALID_ARGUMENT', 'description': description}]
|
|
118
|
-
return ApiResponse(obj)
|
|
119
|
-
else:
|
|
120
|
-
required.update(optional)
|
|
121
|
-
data_str = json.dumps([required])
|
|
122
|
-
return self._request(kwargs.pop('path'), data=data_str, params=kwargs)
|
|
123
|
-
|
|
124
|
-
@sp_endpoint('/v2/sp/campaigns', method='POST')
|
|
125
|
-
@Utils.deprecated
|
|
126
|
-
def create_single_campaign_assistant(
|
|
127
|
-
self,
|
|
128
|
-
campaign_name: str,
|
|
129
|
-
targeting_type: str,
|
|
130
|
-
daily_budget: int,
|
|
131
|
-
start_date: str,
|
|
132
|
-
end_date: str = None,
|
|
133
|
-
campaign_status: str = "enabled",
|
|
134
|
-
portfolio_id: int = None,
|
|
135
|
-
po_number: str = None,
|
|
136
|
-
account_manager: str = None,
|
|
137
|
-
premium_bid_adjustment: bool = None,
|
|
138
|
-
strategy: str = None,
|
|
139
|
-
predicate: str or tuple = None,
|
|
140
|
-
percentage: int or tuple = None,
|
|
141
|
-
**kwargs,
|
|
142
|
-
) -> ApiResponse:
|
|
143
|
-
r"""
|
|
144
|
-
create_single_campaign_assistant(campaign_name: str,targeting_type: str, daily_budget: int, start_date: str, end_date: str = None, campaign_status: str = "enabled", portfolio_id: int = None, po_number: str = None, account_manager: str = None, premium_bid_adjustment: bool = False, strategy:str = None, predicate:str = None, percentage:int = None, **kwargs) -> ApiResponse
|
|
145
|
-
|
|
146
|
-
Creates one campaigns and create the body based on the params provided
|
|
147
|
-
|
|
148
|
-
Kwargs:
|
|
149
|
-
|
|
150
|
-
| **campaign_name** (string): [required] A name for the campaign
|
|
151
|
-
| **campaign_type** (string): [fixed] The advertising product managed by this campaign. Value: sponsoredProducts
|
|
152
|
-
| **targeting_type** (string): [required] The type of targeting for the campaign. Values: manual, auto
|
|
153
|
-
| **daily_budget** (float): [required] A daily budget for the campaign
|
|
154
|
-
| **start_date** (string): [required] A starting date for the campaign to go live. The format of the date is YYYYMMDD
|
|
155
|
-
| **end_date** (string): [optional] An ending date for the campaign to stop running. The format of the date is YYYYMMDD
|
|
156
|
-
| **campaign_status**': (string): [optional] The current resource state Values: enabled, paused, archived. Default: enabled
|
|
157
|
-
| **portfolio_id** (number): [optional] The identifier of an existing portfolio to which the campaign is associated
|
|
158
|
-
| **po_number** (string): [optional] 'A list of advertiser-specified custom identifiers for the campaign. Each customer identifier is a key-value pair. You can specify a maximum of 50 identifiers
|
|
159
|
-
| **account_manager** (string): [optional] A list of advertiser-specified custom identifiers for the campaign. Each customer identifier is a key-value pair. You can specify a maximum of 50 identifiers
|
|
160
|
-
| **premium_bid_adjustment**' (boolean) If set to true, Amazon increases the default bid for ads that are eligible to appear in this placement. See developer notes for more information.
|
|
161
|
-
| **strategy** (string): [optional] The bidding strategy. 'Values': legacyForSales (Dynamic bids - down only), autoForSales (Dynamic bids - up and down), manual (Fixed bid)
|
|
162
|
-
| **predicate** (string): [optional] You can enable controls to adjust your bid based on the placement location. Specify a location where you want to use bid controls. The percentage value set is the percentage of the original bid for which you want to have your bid adjustment increased. For example, a 50% adjustment on a $1.00 bid would increase the bid to $1.50 for the opportunity to win a specified placement. 'Values': placementTop, placementProductPage
|
|
163
|
-
| **percentage** (float): [optional] The bid adjustment percentage value.
|
|
164
|
-
|
|
165
|
-
Returns:
|
|
166
|
-
|
|
167
|
-
ApiResponse
|
|
168
|
-
|
|
169
|
-
"""
|
|
170
|
-
|
|
171
|
-
optional = {}
|
|
172
|
-
|
|
173
|
-
if portfolio_id is not None:
|
|
174
|
-
optional.update({'portfolioId': portfolio_id})
|
|
175
|
-
|
|
176
|
-
if po_number is not None and account_manager is not None:
|
|
177
|
-
optional.update({"tags": {'PONumber': po_number, 'accountManager': account_manager}})
|
|
178
|
-
|
|
179
|
-
if end_date is not None:
|
|
180
|
-
optional.update({'endDate': end_date})
|
|
181
|
-
|
|
182
|
-
if premium_bid_adjustment is not None:
|
|
183
|
-
optional.update({'premiumBidAdjustment': premium_bid_adjustment})
|
|
184
|
-
|
|
185
|
-
if strategy is not None and predicate is not None and percentage is not None:
|
|
186
|
-
if isinstance(predicate, str):
|
|
187
|
-
optional.update(
|
|
188
|
-
{
|
|
189
|
-
'bidding': {
|
|
190
|
-
'strategy': strategy,
|
|
191
|
-
'adjustments': [{'predicate': predicate, 'percentage': percentage}],
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
)
|
|
195
|
-
|
|
196
|
-
if isinstance(predicate, tuple) and len(predicate) == 2 and len(percentage) == 2:
|
|
197
|
-
options = []
|
|
198
|
-
for i in range(len(predicate)):
|
|
199
|
-
option = {"predicate": predicate[i], "percentage": percentage[i]}
|
|
200
|
-
options.append(option)
|
|
201
|
-
|
|
202
|
-
bidding = {'strategy': strategy, 'adjustments': options}
|
|
203
|
-
|
|
204
|
-
dictionary = {}
|
|
205
|
-
dictionary["bidding"] = bidding
|
|
206
|
-
|
|
207
|
-
optional.update(dictionary)
|
|
208
|
-
|
|
209
|
-
required = {
|
|
210
|
-
'name': campaign_name,
|
|
211
|
-
'campaignType': 'sponsoredProducts',
|
|
212
|
-
'targetingType': targeting_type,
|
|
213
|
-
'state': campaign_status,
|
|
214
|
-
'dailyBudget': daily_budget,
|
|
215
|
-
'startDate': start_date,
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
if optional:
|
|
219
|
-
required.update(optional)
|
|
220
|
-
|
|
221
|
-
data_str = json.dumps([required])
|
|
222
|
-
return self._request(kwargs.pop('path'), data=data_str, params=kwargs)
|
|
223
|
-
|
|
224
|
-
@sp_endpoint('/v2/sp/campaigns', method='POST')
|
|
225
|
-
@Utils.deprecated
|
|
226
|
-
def create_campaigns(self, **kwargs) -> ApiResponse:
|
|
227
|
-
r"""
|
|
228
|
-
create_campaigns(body: (dict, str, list)) -> ApiResponse
|
|
229
|
-
|
|
230
|
-
Creates one or more campaigns.
|
|
231
|
-
|
|
232
|
-
body: | REQUIRED {'description': 'An array of campaigns.}'
|
|
233
|
-
|
|
234
|
-
| '**portfolioId**': *number*, {'description': 'The identifier of an existing portfolio to which the campaign is associated'}
|
|
235
|
-
| '**name**': *string*, {'description': 'A name for the campaign'}
|
|
236
|
-
| '**tags**': *string*, {'description': 'A list of advertiser-specified custom identifiers for the campaign. Each customer identifier is a key-value pair. You can specify a maximum of 50 identifiers.'}
|
|
237
|
-
| '**campaignType**': *string*, {'description': 'The advertising product managed by this campaign', 'Enum': '[ sponsoredProducts ]'}
|
|
238
|
-
| '**targetingType**': *string*, {'description': 'The type of targeting for the campaign.', 'Enum': '[ manual, auto ]'}
|
|
239
|
-
| '**state**': *string*, {'description': 'The current resource state.', 'Enum': '[ enabled, paused, archived ]'}
|
|
240
|
-
| '**dailyBudget**': *number($float)*, {'description': 'A daily budget for the campaign.'}
|
|
241
|
-
| '**startDate**': *string*, {'description': 'A starting date for the campaign to go live. The format of the date is YYYYMMDD.'}
|
|
242
|
-
| '**endDate**': *string* nullable: true, {'description': 'An ending date for the campaign to stop running. The format of the date is YYYYMMDD.'}
|
|
243
|
-
| '**premiumBidAdjustment**': *boolean*, {'description': 'If set to true, Amazon increases the default bid for ads that are eligible to appear in this placement. See developer notes for more information.'}
|
|
244
|
-
| '**bidding**': *Bidding*, {'strategy': 'string', 'Enum': '[ legacyForSales, autoForSales, manual ]', 'adjustments': '{...}'}
|
|
245
|
-
|
|
246
|
-
Returns:
|
|
247
|
-
|
|
248
|
-
ApiResponse
|
|
249
|
-
|
|
250
|
-
"""
|
|
251
|
-
body = Utils.convert_body(kwargs.pop('body'))
|
|
252
|
-
return self._request(kwargs.pop('path'), data=body, params=kwargs)
|
|
253
|
-
|
|
254
|
-
@sp_endpoint('/v2/sp/campaigns', method='PUT')
|
|
255
|
-
@Utils.deprecated
|
|
256
|
-
def edit_campaigns(self, **kwargs) -> ApiResponse:
|
|
257
|
-
r"""
|
|
258
|
-
edit_campaigns(body: (dict, str, list)) -> ApiResponse
|
|
259
|
-
|
|
260
|
-
Updates one or more campaigns.
|
|
261
|
-
|
|
262
|
-
body: | REQUIRED {'description': 'An array of campaigns.}'
|
|
263
|
-
|
|
264
|
-
| '**campaignId**': *number*, {'description': 'The identifier of an existing campaign to update.'}
|
|
265
|
-
| '**portfolioId**': *number*, {'description': 'The identifier of an existing portfolio to which the campaign is associated'}
|
|
266
|
-
| '**name**': *string*, {'description': 'The name for the campaign'}
|
|
267
|
-
| '**tags**': *CampaignTags*, {'description': 'A list of advertiser-specified custom identifiers for the campaign. Each customer identifier is a key-value pair. You can specify a maximum of 50 identifiers.'}
|
|
268
|
-
| '**state**': *string*, {'description': 'The current resource state.', 'Enum': '[ enabled, paused, archived ]'}
|
|
269
|
-
| '**dailyBudget**': *number($float)*, {'description': 'The daily budget for the campaign.'}
|
|
270
|
-
| '**startDate**': *string*, {'description': 'The starting date for the campaign to go live. The format of the date is YYYYMMDD.'}
|
|
271
|
-
| '**endDate**': *string* nullable: true, {'description': 'The ending date for the campaign to stop running. The format of the date is YYYYMMDD.'}
|
|
272
|
-
| '**premiumBidAdjustment**': *boolean*, {'description': 'If set to true, Amazon increases the default bid for ads that are eligible to appear in this placement. See developer notes for more information.'}
|
|
273
|
-
| '**bidding**': *Bidding*, {'strategy': 'string', 'Enum': '[ legacyForSales, autoForSales, manual ]', 'adjustments': '{...}'}
|
|
274
|
-
|
|
275
|
-
Returns:
|
|
276
|
-
|
|
277
|
-
ApiResponse
|
|
278
|
-
|
|
279
|
-
"""
|
|
280
|
-
body = Utils.convert_body(kwargs.pop('body'))
|
|
281
|
-
return self._request(kwargs.pop('path'), data=body, params=kwargs)
|
|
282
|
-
|
|
283
|
-
@sp_endpoint('/v2/sp/campaigns', method='GET')
|
|
284
|
-
@Utils.deprecated
|
|
285
|
-
def list_campaigns(self, **kwargs) -> ApiResponse:
|
|
286
|
-
r"""
|
|
287
|
-
list_campaigns(**kwargs) -> ApiResponse
|
|
288
|
-
|
|
289
|
-
Gets an array of campaigns.
|
|
290
|
-
|
|
291
|
-
query **startIndex**:*integer* | Optional. 0-indexed record offset for the result set. Default value : 0
|
|
292
|
-
|
|
293
|
-
query **count**:*integer* | Optional. Number of records to include in the paged response. Defaults to max page size.
|
|
294
|
-
|
|
295
|
-
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.
|
|
296
|
-
|
|
297
|
-
query **name**:*string* | Optional. Restricts results to campaigns with the specified name.
|
|
298
|
-
|
|
299
|
-
query **portfolioIdFilter**:*string* | Optional. A comma-delimited list of portfolio identifiers.
|
|
300
|
-
|
|
301
|
-
query **campaignIdFilter**:*string* | Optional. A comma-delimited list of campaign identifiers.
|
|
302
|
-
|
|
303
|
-
Returns:
|
|
304
|
-
|
|
402
|
+
query_campaigns(body: dict) -> ApiResponse
|
|
403
|
+
|
|
404
|
+
Amazon Ads API v1 - Query Campaigns (operationId: QueryCampaign)
|
|
405
|
+
|
|
406
|
+
Request Body [Required]
|
|
407
|
+
| **adProductFilter** (dict): [required]
|
|
408
|
+
| **include** (list<AdProduct>) : Enum [ AMAZON_DSP, SPONSORED_BRANDS, SPONSORED_DISPLAY, SPONSORED_PRODUCTS, SPONSORED_TELEVISION ]
|
|
409
|
+
| **campaignIdFilter** (dict) [optional]
|
|
410
|
+
| **include** (list<string>) : Campaign identifiers
|
|
411
|
+
| **goalFilter** (dict) [optional]
|
|
412
|
+
| **include** (list<Goal>) : Enum [ AWARENESS, CONSIDERATION, CONVERSIONS ]
|
|
413
|
+
| **marketplaceScopeFilter** (dict) [optional]
|
|
414
|
+
| **include** (list<MarketplaceScope>) : Enum [ GLOBAL, SINGLE_MARKETPLACE ]
|
|
415
|
+
| **nameFilter** (dict) [optional]
|
|
416
|
+
| **include** (list<string>) : Campaign names
|
|
417
|
+
| **queryTermMatchType** (string) : [required] Enum [ BROAD_MATCH, EXACT_MATCH ]
|
|
418
|
+
| **portfolioIdFilter** (dict) [optional]
|
|
419
|
+
| **include** (list<string>) : Portfolio identifiers
|
|
420
|
+
| **retailerScopeFilter** (dict) [optional]
|
|
421
|
+
| **include** (list<RetailerScope>) : Enum [ AMAZON, OTHER_RETAILERS ]
|
|
422
|
+
| **stateFilter** (dict) [optional]
|
|
423
|
+
| **include** (list<State>) : Enum [ ARCHIVED, DRAFT, ENABLED, PAUSED ]
|
|
424
|
+
| **maxResults** (int) [optional] Minimum 1, Maximum 1000
|
|
425
|
+
| **nextToken** (string) [optional] Token to navigate to the next page
|
|
426
|
+
|
|
427
|
+
Headers
|
|
428
|
+
| **Amazon-Ads-AccountId** (string) [optional] Advertiser account identifier
|
|
429
|
+
|
|
430
|
+
Returns
|
|
305
431
|
ApiResponse
|
|
432
|
+
| **campaigns** (list), **nextToken** (string)
|
|
306
433
|
|
|
307
434
|
"""
|
|
308
|
-
|
|
435
|
+
schema_version = 'application/json'
|
|
436
|
+
headers = {"Accept": schema_version, "Content-Type": schema_version}
|
|
437
|
+
return self._request(kwargs.pop('path'), data=Utils.convert_body(kwargs.pop('body'), False), params=kwargs, headers=headers)
|
|
309
438
|
|
|
310
|
-
@sp_endpoint('/
|
|
311
|
-
|
|
312
|
-
def get_campaign(self, campaignId, **kwargs) -> ApiResponse:
|
|
439
|
+
@sp_endpoint('/adsApi/v1/delete/campaigns', method='POST')
|
|
440
|
+
def delete_campaigns(self, **kwargs) -> ApiResponse:
|
|
313
441
|
r"""
|
|
442
|
+
delete_campaigns(body: dict) -> ApiResponse
|
|
314
443
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
Gets a campaign specified by identifier.
|
|
444
|
+
Amazon Ads API v1 - Delete Campaigns (operationId: DeleteCampaign)
|
|
318
445
|
|
|
319
|
-
|
|
446
|
+
Request Body [Required]
|
|
447
|
+
| **campaignIds** (list<string>) : [required] Campaign identifiers to delete
|
|
320
448
|
|
|
321
|
-
|
|
449
|
+
Headers
|
|
450
|
+
| **Amazon-Ads-AccountId** (string) [optional] Advertiser account identifier
|
|
322
451
|
|
|
452
|
+
Returns
|
|
323
453
|
ApiResponse
|
|
454
|
+
| **207** MultiStatus response with partial errors. Inspect the payload
|
|
455
|
+
to know which campaign ids succeeded and which failed.
|
|
324
456
|
|
|
325
457
|
"""
|
|
326
|
-
|
|
458
|
+
schema_version = 'application/json'
|
|
459
|
+
headers = {"Accept": schema_version, "Content-Type": schema_version}
|
|
460
|
+
return self._request(kwargs.pop('path'), data=Utils.convert_body(kwargs.pop('body'), False), params=kwargs, headers=headers)
|
|
327
461
|
|
|
328
|
-
@sp_endpoint('/
|
|
329
|
-
|
|
330
|
-
def delete_campaign(self, campaignId, **kwargs) -> ApiResponse:
|
|
462
|
+
@sp_endpoint('/adsApi/v1/update/campaigns', method='POST')
|
|
463
|
+
def update_campaigns(self, **kwargs) -> ApiResponse:
|
|
331
464
|
r"""
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
465
|
+
update_campaigns(body: dict) -> ApiResponse
|
|
466
|
+
|
|
467
|
+
Amazon Ads API v1 - Update Campaigns (operationId: UpdateCampaign)
|
|
468
|
+
|
|
469
|
+
Request Body [Required]
|
|
470
|
+
| **campaigns** (list<dict>) : [required] One or more campaign objects to update.
|
|
471
|
+
Each object requires **campaignId** and may include any of the fields below.
|
|
472
|
+
|
|
473
|
+
Campaign fields [optional except campaignId]
|
|
474
|
+
| **campaignId** (string) : [required] The identifier of the campaign to update.
|
|
475
|
+
| **adProduct** (string) : Enum [ AMAZON_DSP, SPONSORED_BRANDS, SPONSORED_DISPLAY, SPONSORED_PRODUCTS, SPONSORED_TELEVISION ]
|
|
476
|
+
| **name** (string) : The name of the campaign.
|
|
477
|
+
| **state** (string) : Enum [ DRAFT, ENABLED, PAUSED ]
|
|
478
|
+
| **budgets** (list<dict>) : Budget objects for the campaign.
|
|
479
|
+
| **startDateTime** (string) : Campaign start date and time.
|
|
480
|
+
| **endDateTime** (string) : Campaign end date and time.
|
|
481
|
+
| **portfolioId** (string) : The identifier of the portfolio.
|
|
482
|
+
| **purchaseOrderNumber** (string) : Advertiser purchase order number.
|
|
483
|
+
| **tags** (list<dict>) : Advertiser-specified custom identifiers.
|
|
484
|
+
| **marketplaces** (list<dict>) : Marketplaces where the campaign runs.
|
|
485
|
+
| **marketplaceConfigurations** (list<dict>) : Per-marketplace overrides.
|
|
486
|
+
| **countries** (list<string>) : Country codes.
|
|
487
|
+
| **costType** (string) : Enum [ CPC, CPM, FIXED_PRICE, VCPM ]
|
|
488
|
+
| **fees** (list<dict>) : Fee definitions.
|
|
489
|
+
| **flights** (list<dict>) : Flight schedules.
|
|
490
|
+
| **frequencies** (list<dict>) : Frequency cap definitions.
|
|
491
|
+
| **optimizations** (dict) : Campaign optimization settings.
|
|
492
|
+
| **siteRestrictions** (list<dict>) : Site restrictions.
|
|
493
|
+
| **skanAppId** (string) : SKAdNetwork app id.
|
|
494
|
+
| **targetedPGDealId** (string) : Targeted programmatic guaranteed deal id.
|
|
495
|
+
| **adomains** (list<string>) : Ad domains.
|
|
496
|
+
|
|
497
|
+
Headers
|
|
498
|
+
| **Amazon-Ads-AccountId** (string) [optional] Advertiser account identifier
|
|
499
|
+
|
|
500
|
+
Returns
|
|
368
501
|
ApiResponse
|
|
502
|
+
| **207** MultiStatus response with partial errors. Inspect the payload
|
|
503
|
+
to know which campaigns succeeded and which failed.
|
|
369
504
|
|
|
370
505
|
"""
|
|
371
|
-
|
|
506
|
+
schema_version = 'application/json'
|
|
507
|
+
headers = {"Accept": schema_version, "Content-Type": schema_version}
|
|
508
|
+
return self._request(kwargs.pop('path'), data=Utils.convert_body(kwargs.pop('body'), False), params=kwargs, headers=headers)
|
|
372
509
|
|
|
373
|
-
@sp_endpoint('/
|
|
374
|
-
|
|
375
|
-
def get_campaign_extended(self, campaignId, **kwargs) -> ApiResponse:
|
|
510
|
+
@sp_endpoint('/adsApi/v1/create/campaigns', method='POST')
|
|
511
|
+
def create_campaigns(self, **kwargs) -> ApiResponse:
|
|
376
512
|
r"""
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
513
|
+
create_campaigns(body: dict) -> ApiResponse
|
|
514
|
+
|
|
515
|
+
Amazon Ads API v1 - Create Campaigns (operationId: CreateCampaign)
|
|
516
|
+
|
|
517
|
+
Request Body [Required]
|
|
518
|
+
| **campaigns** (list<dict>) : [required] One or more campaign objects to create.
|
|
519
|
+
Each object requires **adProduct**, **name** and **state**.
|
|
520
|
+
|
|
521
|
+
Campaign fields
|
|
522
|
+
| **adProduct** (string) : [required] Enum [ AMAZON_DSP, SPONSORED_BRANDS, SPONSORED_DISPLAY, SPONSORED_PRODUCTS, SPONSORED_TELEVISION ]
|
|
523
|
+
| **name** (string) : [required] The name of the campaign.
|
|
524
|
+
| **state** (string) : [required] Enum [ DRAFT, ENABLED, PAUSED ]
|
|
525
|
+
| **budgets** (list<dict>) : Budget objects for the campaign.
|
|
526
|
+
| **budgetType** (string) : [required] Budget type.
|
|
527
|
+
| **budgetValue** (dict) : [required] Budget amount.
|
|
528
|
+
| **recurrenceTimePeriod** (string) : [required] Recurrence period.
|
|
529
|
+
| **startDateTime** (string) : Campaign start date and time.
|
|
530
|
+
| **endDateTime** (string) : Campaign end date and time.
|
|
531
|
+
| **portfolioId** (string) : The identifier of the portfolio.
|
|
532
|
+
| **purchaseOrderNumber** (string) : Advertiser purchase order number.
|
|
533
|
+
| **tags** (list<dict>) : [required key+value] Advertiser-specified custom identifiers.
|
|
534
|
+
| **marketplaces** (list<dict>) : Marketplaces where the campaign runs.
|
|
535
|
+
| **marketplaceConfigurations** (list<dict>) : Per-marketplace overrides, each with
|
|
536
|
+
**marketplace** and **overrides** (both required).
|
|
537
|
+
| **countries** (list<string>) : Country codes.
|
|
538
|
+
| **costType** (string) : Enum [ CPC, CPM, FIXED_PRICE, VCPM ]
|
|
539
|
+
| **fees** (list<dict>) : [required feeType+feeValue+feeValueType] Fee definitions.
|
|
540
|
+
| **flights** (list<dict>) : [required budget+startDateTime+endDateTime] Flight schedules.
|
|
541
|
+
| **frequencies** (list<dict>) : [required eventMaxCount+frequencyTargetingSetting+
|
|
542
|
+
timeCount+timeUnit] Frequency cap definitions.
|
|
543
|
+
| **optimizations** (dict) : Campaign optimization settings.
|
|
544
|
+
| **siteRestrictions** (list<dict>) : Site restrictions.
|
|
545
|
+
| **brandId** (string) : Brand identifier.
|
|
546
|
+
| **skanAppId** (string) : SKAdNetwork app id.
|
|
547
|
+
| **targetedPGDealId** (string) : Targeted programmatic guaranteed deal id.
|
|
548
|
+
| **adomains** (list<string>) : Ad domains.
|
|
549
|
+
| **autoCreationSettings** (dict) : Automatic creation settings.
|
|
550
|
+
|
|
551
|
+
Headers
|
|
552
|
+
| **Amazon-Ads-AccountId** (string) [optional] Advertiser account identifier
|
|
553
|
+
|
|
554
|
+
Returns
|
|
385
555
|
ApiResponse
|
|
556
|
+
| **207** MultiStatus response with partial errors. Inspect the payload
|
|
557
|
+
to know which campaigns were created and which failed.
|
|
386
558
|
|
|
387
559
|
"""
|
|
388
|
-
|
|
560
|
+
schema_version = 'application/json'
|
|
561
|
+
headers = {"Accept": schema_version, "Content-Type": schema_version}
|
|
562
|
+
return self._request(kwargs.pop('path'), data=Utils.convert_body(kwargs.pop('body'), False), params=kwargs, headers=headers)
|
ad_api/api/sp/campaigns_v3.py
CHANGED
|
@@ -73,6 +73,7 @@ class CampaignsV3(Client):
|
|
|
73
73
|
return self._request(kwargs.pop('path'), data=Utils.convert_body(kwargs.pop('body'), False), params=kwargs, headers=headers)
|
|
74
74
|
|
|
75
75
|
@sp_endpoint('/sp/campaigns/list', method='POST')
|
|
76
|
+
@Utils.deprecated
|
|
76
77
|
def list_campaigns(self, version: int = 3, **kwargs) -> ApiResponse:
|
|
77
78
|
r"""
|
|
78
79
|
list_campaigns(body: (dict, str, list)) -> ApiResponse
|
ad_api/version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "0.9.
|
|
1
|
+
__version__ = "0.9.8"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-amazon-ad-api
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.8
|
|
4
4
|
Summary: Python wrapper for the Amazon Advertising API
|
|
5
5
|
Home-page: https://github.com/denisneuf/python-amazon-ad-api
|
|
6
6
|
Author: Daniel Alvaro
|
|
@@ -15,7 +15,7 @@ License-File: LICENSE
|
|
|
15
15
|
Requires-Dist: requests<2.35.0,>=2.27.1
|
|
16
16
|
Requires-Dist: six<1.18,>=1.16
|
|
17
17
|
Requires-Dist: cachetools<7.3,>=5.0
|
|
18
|
-
Requires-Dist: pycryptodome<4.
|
|
18
|
+
Requires-Dist: pycryptodome<4.2,>=3.13
|
|
19
19
|
Requires-Dist: pytz<2027.0,>=2021.3
|
|
20
20
|
Requires-Dist: confuse<2.4,>=1.7
|
|
21
21
|
Dynamic: author
|
|
@@ -299,6 +299,34 @@ There is a new version 3 Portfolios API, please check the [migration guide](http
|
|
|
299
299
|
* [Get test account information](https://python-amazon-ad-api.readthedocs.io/en/latest/api/advertising_test_account.html#ad_api.api.AdvertisingTestAccount.AdvertisingTestAccount.get_test_account)
|
|
300
300
|
|
|
301
301
|
|
|
302
|
+
### Sponsored Products v1 (new)
|
|
303
|
+
|
|
304
|
+
New unified endpoint generation. Campaigns are queried with a single `POST /adsApi/v1/query/campaigns` resource instead of the versioned v2/v3 endpoints.
|
|
305
|
+
|
|
306
|
+
| Method | Endpoint | Body |
|
|
307
|
+
|---|---|---|
|
|
308
|
+
| `query_campaigns` | `POST /adsApi/v1/query/campaigns` | filters + `maxResults`/`nextToken` |
|
|
309
|
+
| `create_campaigns` | `POST /adsApi/v1/create/campaigns` | `campaigns[]` (`adProduct`, `name`, `state` required) |
|
|
310
|
+
| `update_campaigns` | `POST /adsApi/v1/update/campaigns` | `campaigns[]` (`campaignId` required) |
|
|
311
|
+
| `delete_campaigns` | `POST /adsApi/v1/delete/campaigns` | `campaignIds[]` |
|
|
312
|
+
|
|
313
|
+
All four return a **207 MultiStatus** response (except `query_campaigns`, which returns 200), so check the payload for per-entity errors.
|
|
314
|
+
|
|
315
|
+
```python
|
|
316
|
+
from ad_api.api import sponsored_products
|
|
317
|
+
|
|
318
|
+
result = sponsored_products.Campaigns(credentials=credentials, debug=True).query_campaigns(
|
|
319
|
+
body={
|
|
320
|
+
"adProductFilter": {"include": ["SPONSORED_PRODUCTS"]},
|
|
321
|
+
"stateFilter": {"include": ["ENABLED"]},
|
|
322
|
+
"maxResults": 100,
|
|
323
|
+
}
|
|
324
|
+
)
|
|
325
|
+
|
|
326
|
+
campaigns = result.payload.get("campaigns")
|
|
327
|
+
next_token = result.payload.get("nextToken")
|
|
328
|
+
```
|
|
329
|
+
|
|
302
330
|
### [Modules Available Sponsored Products 2.0](https://python-amazon-ad-api.readthedocs.io/en/latest/sp_v2.html)
|
|
303
331
|
|
|
304
332
|
Warning: [PLANNED DEPRECATION 6/30/2023]
|
|
@@ -307,6 +335,8 @@ There is a new version 3 of Sponsored Product API, please check the [migration g
|
|
|
307
335
|
|
|
308
336
|
### [Modules Available Sponsored Products 3.0](https://python-amazon-ad-api.readthedocs.io/en/latest/sp_v3.html)
|
|
309
337
|
|
|
338
|
+
Warning: `list_campaigns` is deprecated. Use the v1 `query_campaigns` method instead.
|
|
339
|
+
|
|
310
340
|
|
|
311
341
|
* [ThemeBased Bid Recommendation](https://python-amazon-ad-api.readthedocs.io/en/latest/sp/bid_recommendations_v3.html)
|
|
312
342
|
* [Keyword Recommendations](https://python-amazon-ad-api.readthedocs.io/en/latest/sp/ranked_keywords_recommendations.html)
|
|
@@ -375,7 +405,9 @@ There is a new version 3 of Sponsored Product API, please check the [migration g
|
|
|
375
405
|
|
|
376
406
|
* [Reports](https://python-amazon-ad-api.readthedocs.io/en/latest/dsp/reports.html)
|
|
377
407
|
|
|
378
|
-
### Simple Example Usage Campaigns with Credentials
|
|
408
|
+
### Simple Example Usage Campaigns with Credentials (v3, legacy)
|
|
409
|
+
|
|
410
|
+
Warning: this example uses `CampaignsV3.list_campaigns`, which is deprecated. See the v1 `query_campaigns` example above.
|
|
379
411
|
|
|
380
412
|
```python
|
|
381
413
|
import logging
|
|
@@ -443,4 +475,4 @@ We are not affiliated with Amazon but they used our api :)
|
|
|
443
475
|
|
|
444
476
|
|
|
445
477
|
---
|
|
446
|
-
*Last release: v0.
|
|
478
|
+
*Last release: v0.9.7*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
ad_api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
ad_api/version.py,sha256=
|
|
2
|
+
ad_api/version.py,sha256=GI3Cr15wC6XhdahtMoSOf62d2gYve5G_PiR_xx_RGKc,22
|
|
3
3
|
ad_api/api/__init__.py,sha256=rurlFrTJZgSGNdkEahAJGjDAVll2KyCqpLpV40ZKI6o,1487
|
|
4
4
|
ad_api/api/account.py,sha256=CmOvCfHoPWaeTUJvtB0pNoNulZVSz4oMMCKIpVTpHos,2931
|
|
5
5
|
ad_api/api/advertising_test_account.py,sha256=btOVbdk2tBDmyKSJaQbcIFyzNG8KFJVUmTe4p9xMhpU,1507
|
|
@@ -83,9 +83,9 @@ ad_api/api/sp/campaign_consolidated_recommendations.py,sha256=AZS8A0ZH_GRCZ5uExq
|
|
|
83
83
|
ad_api/api/sp/campaign_negative_keywords.py,sha256=4Jj8CFt4YX36N4YhXDDVabOiPOfCtQ2kYqYoS2Xejoc,6344
|
|
84
84
|
ad_api/api/sp/campaign_negative_keywords_v3.py,sha256=3y5PHA_r6GtBAFbAXiGH5q6ByWsG2alA3DCqdRiaO3w,6592
|
|
85
85
|
ad_api/api/sp/campaign_negative_targets.py,sha256=5fzt3wU1omOrGELtwSs4-R1BCcaT8z5H0StjJfCuc9k,8310
|
|
86
|
-
ad_api/api/sp/campaigns.py,sha256=
|
|
86
|
+
ad_api/api/sp/campaigns.py,sha256=L_6lHAT3mrwyP9K4xqwgMBTzth5_oSMSNZNhpaVoH6o,30910
|
|
87
87
|
ad_api/api/sp/campaigns_budget_usage.py,sha256=njn-Wd3xvbJbL5HMSNQK4RyxCgAflqUgVFo7XhlXmB8,862
|
|
88
|
-
ad_api/api/sp/campaigns_v3.py,sha256=
|
|
88
|
+
ad_api/api/sp/campaigns_v3.py,sha256=enxuRqoyBeidwR9J5VcPHFDRbiy2G6EEQqKRyaJPI5I,7831
|
|
89
89
|
ad_api/api/sp/campaings_optimization.py,sha256=CrH9x-KNTsRc56tn_TCDxDTZIF9pYdqDT48LTepys2w,6673
|
|
90
90
|
ad_api/api/sp/keywords.py,sha256=DR_y4BUrL2P_lSqw3RwHmIBFI634ekbCaEHDuDqyqwI,7851
|
|
91
91
|
ad_api/api/sp/keywords_v3.py,sha256=tvpNY0rzCeLVNGLdN2NNa8Y9DyAH9D3GQUnaEieYpXE,3850
|
|
@@ -118,8 +118,8 @@ ad_api/base/exceptions.py,sha256=9D3M40ZIlLS0fA-aQh1BTWPOW-Nvf0tRhbA85jFnDJ4,438
|
|
|
118
118
|
ad_api/base/helpers.py,sha256=naUkDLK466x_OBCPXxMlzRc2nPC6iQ6H_vyUji0MJJ0,2282
|
|
119
119
|
ad_api/base/marketplaces.py,sha256=44lvCcluXNpqTprWQ80e3weSQmQbJoWL-WDSOWVbCyQ,4657
|
|
120
120
|
ad_api/base/utils.py,sha256=_qnCBOvyJTLgaZjJzUWTi38GGLHkQszXELs79133Rb4,5618
|
|
121
|
-
python_amazon_ad_api-0.9.
|
|
122
|
-
python_amazon_ad_api-0.9.
|
|
123
|
-
python_amazon_ad_api-0.9.
|
|
124
|
-
python_amazon_ad_api-0.9.
|
|
125
|
-
python_amazon_ad_api-0.9.
|
|
121
|
+
python_amazon_ad_api-0.9.8.dist-info/licenses/LICENSE,sha256=h2rpqlmmLy-4l1tN6KpWAFxx1JEMYeEFrMrZUbx_B_o,1105
|
|
122
|
+
python_amazon_ad_api-0.9.8.dist-info/METADATA,sha256=9mf-kIA1iXGxcU5F7Dn7z8L8FrWEhvHnxmJRkQcaCk4,20491
|
|
123
|
+
python_amazon_ad_api-0.9.8.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
124
|
+
python_amazon_ad_api-0.9.8.dist-info/top_level.txt,sha256=nN9twUos-8pkP514ZwpvRU9YL9L2XyQyHsMQFfudGTU,7
|
|
125
|
+
python_amazon_ad_api-0.9.8.dist-info/RECORD,,
|
|
File without changes
|
{python_amazon_ad_api-0.9.6.dist-info → python_amazon_ad_api-0.9.8.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
|
File without changes
|