python-amazon-ad-api 2.2.2__py3-none-any.whl → 2.2.4__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.
@@ -0,0 +1,36 @@
1
+ """Sponsored TV /st/creatives/preview.
2
+
3
+ Contract: Sponsored TV 3.0, ``/st/creatives/preview``. Every route needs the profile
4
+ scope, so each one declares ``Amazon-Advertising-API-Scope``; the body media
5
+ type is ``stCreativesPreview.v<version>+json``.
6
+
7
+ ``Prefer`` is not an identity header.
8
+ """
9
+
10
+ from ad_api.base import Client, sp_endpoint, ApiResponse, Utils
11
+
12
+
13
+ class CreativesPreview(Client):
14
+ r"""Sponsored TV - /st/creatives/preview"""
15
+
16
+ @sp_endpoint('/st/creatives/preview', method='POST', headers=['Amazon-Advertising-API-Scope'])
17
+ def preview_creative(self, version: int = 1, prefer: str = '', **kwargs) -> ApiResponse:
18
+ r"""
19
+ Previews a Sponsored TV creative.
20
+
21
+ Request Body [Required]
22
+ | **previewConfiguration** (object) [required].
23
+ | **creativeId** (string) [optional]: either this or **assetProperties**.
24
+ | **assetProperties** (object) [optional]: alternative to ``creativeId``; the two cannot be combined.
25
+
26
+ Keyword Args
27
+
28
+ - ``version`` (int): media type version. Defaults to 1.
29
+
30
+ Returns
31
+ ApiResponse with the preview.
32
+ """
33
+ schema = 'application/vnd.stCreativesPreview.v' + str(version) + '+json'
34
+ headers = {'Accept': schema, 'Content-Type': schema}
35
+ body = Utils.convert_body(kwargs.pop('body'), False)
36
+ return self._request(kwargs.pop('path'), data=body, params=kwargs, headers=headers)
@@ -0,0 +1,36 @@
1
+ """Sponsored TV /st/forecasts.
2
+
3
+ Contract: Sponsored TV 3.0, ``/st/forecasts``. Every route needs the profile
4
+ scope, so each one declares ``Amazon-Advertising-API-Scope``; the body media
5
+ type is ``stForecast.v<version>+json``.
6
+
7
+ ``Prefer`` is not an identity header.
8
+ """
9
+
10
+ from ad_api.base import Client, sp_endpoint, ApiResponse, Utils
11
+
12
+
13
+ class Forecasts(Client):
14
+ r"""Sponsored TV - /st/forecasts"""
15
+
16
+ @sp_endpoint('/st/forecasts', method='POST', headers=['Amazon-Advertising-API-Scope'])
17
+ def forecast(self, version: int = 1, prefer: str = '', **kwargs) -> ApiResponse:
18
+ r"""
19
+ Asks for a performance forecast of a Sponsored TV configuration.
20
+
21
+ Request Body [Required]
22
+ | **adGroup**, **campaign**, **creative** (objects).
23
+ | **ads** (list): 1 to 100 product ads.
24
+ | **locationTargetingClauses** (list).
25
+
26
+ Keyword Args
27
+
28
+ - ``version`` (int): media type version. Defaults to 1.
29
+
30
+ Returns
31
+ ApiResponse with the forecast.
32
+ """
33
+ schema = 'application/vnd.stForecast.v' + str(version) + '+json'
34
+ headers = {'Accept': schema, 'Content-Type': schema}
35
+ body = Utils.convert_body(kwargs.pop('body'), False)
36
+ return self._request(kwargs.pop('path'), data=body, params=kwargs, headers=headers)
@@ -0,0 +1,76 @@
1
+ """Sponsored TV /st/locations.
2
+
3
+ Contract: Sponsored TV 3.0, ``/st/locations``. Every route needs the profile
4
+ scope, so each one declares ``Amazon-Advertising-API-Scope``; the body media
5
+ type is ``stLocation.v<version>+json``.
6
+
7
+ ``Prefer`` is not an identity header.
8
+ """
9
+
10
+ from ad_api.base import Client, sp_endpoint, ApiResponse, Utils
11
+
12
+
13
+ class Locations(Client):
14
+ r"""Sponsored TV - /st/locations"""
15
+
16
+ @sp_endpoint('/st/locations', method='POST', headers=['Amazon-Advertising-API-Scope'])
17
+ def create_locations(self, version: int = 1, prefer: str = '', **kwargs) -> ApiResponse:
18
+ r"""
19
+ Creates Sponsored TV locations.
20
+
21
+ Request Body [Required]
22
+ | **locations** (list): each one with **adGroupId** and **locationId**, the Amazon Common Identifier.
23
+
24
+ Keyword Args
25
+
26
+ - ``version`` (int): media type version. Defaults to 1.
27
+
28
+ Returns
29
+ ApiResponse with ``locations``: ``success`` and ``error`` lists.
30
+ """
31
+ schema = 'application/vnd.stLocation.v' + str(version) + '+json'
32
+ headers = {'Accept': schema, 'Content-Type': schema}
33
+ body = Utils.convert_body(kwargs.pop('body'), False)
34
+ return self._request(kwargs.pop('path'), data=body, params=kwargs, headers=headers)
35
+
36
+ @sp_endpoint('/st/locations/delete', method='POST', headers=['Amazon-Advertising-API-Scope'])
37
+ def delete_locations(self, version: int = 1, prefer: str = '', **kwargs) -> ApiResponse:
38
+ r"""
39
+ Deletes Sponsored TV locations. The ids travel in the **body**.
40
+
41
+ Request Body [Required]
42
+ | **locationExpressionIdFilter** (object) [required]: ``{"include": [...]}``.
43
+
44
+ Keyword Args
45
+
46
+ - ``version`` (int): media type version. Defaults to 1.
47
+
48
+ Returns
49
+ ApiResponse with ``locations``: ``success`` and ``error`` lists.
50
+ """
51
+ schema = 'application/vnd.stLocation.v' + str(version) + '+json'
52
+ headers = {'Accept': schema, 'Content-Type': schema}
53
+ body = Utils.convert_body(kwargs.pop('body'), False)
54
+ return self._request(kwargs.pop('path'), data=body, params=kwargs, headers=headers)
55
+
56
+ @sp_endpoint('/st/locations/list', method='POST', headers=['Amazon-Advertising-API-Scope'])
57
+ def list_locations(self, version: int = 1, prefer: str = '', **kwargs) -> ApiResponse:
58
+ r"""
59
+ Lists Sponsored TV locations.
60
+
61
+ Request Body [Optional]
62
+ | **adGroupIdFilter**, **campaignIdFilter**, **locationExpressionIdFilter** (objects): each ``{"include": [...]}``.
63
+ | **maxResults** (int): 1 to 1000.
64
+ | **nextToken** (string): pagination token.
65
+
66
+ Keyword Args
67
+
68
+ - ``version`` (int): media type version. Defaults to 1.
69
+
70
+ Returns
71
+ ApiResponse with the locations, ``nextToken`` and ``totalResults``.
72
+ """
73
+ schema = 'application/vnd.stLocation.v' + str(version) + '+json'
74
+ headers = {'Accept': schema, 'Content-Type': schema}
75
+ body = kwargs.pop('body', None)
76
+ return self._request(kwargs.pop('path'), params=kwargs, headers=headers, **({'data': Utils.convert_body(body, False)} if body is not None else {}))
@@ -0,0 +1,111 @@
1
+ """Sponsored TV /st/targets.
2
+
3
+ Contract: Sponsored TV 3.0, ``/st/targets``. Every route needs the profile
4
+ scope, so each one declares ``Amazon-Advertising-API-Scope``; the body media
5
+ type is ``stTargetingClause.v<version>+json``.
6
+
7
+ ``Prefer`` is not an identity header. The contract allows
8
+ ``include=extendedData`` on list and ``return=representation`` on create,
9
+ update and delete, optionally combined.
10
+ """
11
+
12
+ from ad_api.base import Client, sp_endpoint, ApiResponse, Utils
13
+
14
+
15
+ class Targets(Client):
16
+ r"""Sponsored TV - /st/targets"""
17
+
18
+ @sp_endpoint('/st/targets', method='POST', headers=['Amazon-Advertising-API-Scope'])
19
+ def create_targets(self, version: int = 1, prefer: str = '', **kwargs) -> ApiResponse:
20
+ r"""
21
+ Creates Sponsored TV targeting clauses.
22
+
23
+ Request Body [Required]
24
+ | **targetingClauses** (list): each one with **adGroupId** and **expression**.
25
+ The contract also declares a ``bid`` on the clause, marked deprecated: bids live at ad group level.
26
+
27
+ Keyword Args
28
+
29
+ - ``version`` (int): media type version. Defaults to 1.
30
+ - ``prefer`` (str): ``return=representation``, optionally with ``include=extendedData``. [optional]
31
+
32
+ Returns
33
+ ApiResponse with ``targetingClauses``: ``success`` and ``error`` lists.
34
+ """
35
+ schema = 'application/vnd.stTargetingClause.v' + str(version) + '+json'
36
+ headers = {'Accept': schema, 'Content-Type': schema}
37
+ if prefer:
38
+ headers.update({'Prefer': prefer})
39
+ body = Utils.convert_body(kwargs.pop('body'), False)
40
+ return self._request(kwargs.pop('path'), data=body, params=kwargs, headers=headers)
41
+
42
+ @sp_endpoint('/st/targets', method='PUT', headers=['Amazon-Advertising-API-Scope'])
43
+ def update_targets(self, version: int = 1, prefer: str = '', **kwargs) -> ApiResponse:
44
+ r"""
45
+ Updates Sponsored TV targeting clauses.
46
+
47
+ Request Body [Required]
48
+ | **targetingClauses** (list): each one with **targetId** and **state**; ``bid`` is deprecated.
49
+
50
+ Keyword Args
51
+
52
+ - ``version`` (int): media type version. Defaults to 1.
53
+ - ``prefer`` (str): ``return=representation``, optionally with ``include=extendedData``. [optional]
54
+
55
+ Returns
56
+ ApiResponse with ``targetingClauses``: ``success`` and ``error`` lists.
57
+ """
58
+ schema = 'application/vnd.stTargetingClause.v' + str(version) + '+json'
59
+ headers = {'Accept': schema, 'Content-Type': schema}
60
+ if prefer:
61
+ headers.update({'Prefer': prefer})
62
+ body = Utils.convert_body(kwargs.pop('body'), False)
63
+ return self._request(kwargs.pop('path'), data=body, params=kwargs, headers=headers)
64
+
65
+ @sp_endpoint('/st/targets/delete', method='POST', headers=['Amazon-Advertising-API-Scope'])
66
+ def delete_targets(self, version: int = 1, prefer: str = '', **kwargs) -> ApiResponse:
67
+ r"""
68
+ Deletes Sponsored TV targeting clauses. The ids travel in the **body**.
69
+
70
+ Request Body [Required]
71
+ | **targetIdFilter** (object) [required]: ``{"include": [targetId, ...]}``.
72
+
73
+ Keyword Args
74
+
75
+ - ``version`` (int): media type version. Defaults to 1.
76
+ - ``prefer`` (str): ``return=representation``, optionally with ``include=extendedData``. [optional]
77
+
78
+ Returns
79
+ ApiResponse with ``targetingClauses``: ``success`` and ``error`` lists.
80
+ """
81
+ schema = 'application/vnd.stTargetingClause.v' + str(version) + '+json'
82
+ headers = {'Accept': schema, 'Content-Type': schema}
83
+ if prefer:
84
+ headers.update({'Prefer': prefer})
85
+ body = Utils.convert_body(kwargs.pop('body'), False)
86
+ return self._request(kwargs.pop('path'), data=body, params=kwargs, headers=headers)
87
+
88
+ @sp_endpoint('/st/targets/list', method='POST', headers=['Amazon-Advertising-API-Scope'])
89
+ def list_targets(self, version: int = 1, prefer: str = '', **kwargs) -> ApiResponse:
90
+ r"""
91
+ Lists Sponsored TV targeting clauses.
92
+
93
+ Request Body [Optional]
94
+ | **adGroupIdFilter**, **campaignIdFilter**, **fullFunnelCampaignIdFilter** (objects): each ``{"include": [...]}``.
95
+ | **maxResults** (int): 1 to 100.
96
+ | **nextToken** (string): pagination token.
97
+
98
+ Keyword Args
99
+
100
+ - ``version`` (int): media type version. Defaults to 1.
101
+ - ``prefer`` (str): ``include=extendedData``, optionally with ``return=representation``. [optional]
102
+
103
+ Returns
104
+ ApiResponse with the targeting clauses, ``nextToken`` and ``totalResults``.
105
+ """
106
+ schema = 'application/vnd.stTargetingClause.v' + str(version) + '+json'
107
+ headers = {'Accept': schema, 'Content-Type': schema}
108
+ if prefer:
109
+ headers.update({'Prefer': prefer})
110
+ body = kwargs.pop('body', None)
111
+ return self._request(kwargs.pop('path'), params=kwargs, headers=headers, **({'data': Utils.convert_body(body, False)} if body is not None else {}))
ad_api/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "2.2.2"
1
+ __version__ = "2.2.4"
@@ -0,0 +1,373 @@
1
+ Metadata-Version: 2.4
2
+ Name: python-amazon-ad-api
3
+ Version: 2.2.4
4
+ Summary: Python wrapper for the Amazon Advertising API
5
+ Home-page: https://github.com/denisneuf/python-amazon-ad-api
6
+ Author: Daniel Alvaro
7
+ Author-email: denisneuf@hotmail.com
8
+ License: MIT
9
+ Project-URL: Bug Tracker, https://github.com/denisneuf/python-amazon-ad-api/issues
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE
15
+ Requires-Dist: requests<2.35.0,>=2.27.1
16
+ Requires-Dist: six<1.18,>=1.16
17
+ Requires-Dist: cachetools<8.1,>=5.0
18
+ Requires-Dist: pycryptodome<4.7,>=3.13
19
+ Requires-Dist: pytz<2027.0,>=2021.3
20
+ Requires-Dist: confuse<2.4,>=1.7
21
+ Dynamic: author
22
+ Dynamic: author-email
23
+ Dynamic: home-page
24
+ Dynamic: license
25
+ Dynamic: license-file
26
+ Dynamic: requires-dist
27
+ Dynamic: summary
28
+
29
+ # PYTHON-AMAZON-AD-API
30
+
31
+ ![CodeQL](https://img.shields.io/badge/coverage-82%25-green)
32
+ ![CodeQL](https://img.shields.io/badge/Docs-sphinx-green)
33
+ ![CodeQL](https://img.shields.io/github/v/release/denisneuf/python-amazon-ad-api)
34
+ [![Documentation Status](https://readthedocs.org/projects/python-amazon-ad-api/badge/?version=latest)](https://python-amazon-ad-api.readthedocs.io/en/latest/?badge=latest)
35
+ ![PyPI Downloads](https://static.pepy.tech/badge/python-amazon-ad-api)
36
+ [![Downloads](https://static.pepy.tech/badge/python-amazon-ad-api/month)](https://pepy.tech/project/python-amazon-ad-api)
37
+ [![Downloads](https://static.pepy.tech/badge/python-amazon-ad-api/week)](https://pepy.tech/project/python-amazon-ad-api)
38
+
39
+ ## Amazon's Advertising API
40
+
41
+ A python 3 wrapper to access Amazon's Advertising API with an easy-to-use interface.
42
+
43
+ ### Install
44
+
45
+ [![Badge](https://img.shields.io/pypi/v/python-amazon-ad-api?style=for-the-badge)](https://pypi.org/project/python-amazon-ad-api/)
46
+
47
+ ```
48
+ pip install python-amazon-ad-api
49
+ ```
50
+
51
+ ### Donate
52
+
53
+ If you find this project is useful consider donating or [sponsor](https://github.com/sponsors/denisneuf) it to keep on going on it, thank you.
54
+
55
+ [![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.com/donate?hosted_button_id=G3KB6M2G9YV9C)
56
+
57
+ ![alt text](https://github.com/denisneuf/python-amazon-ad-api/blob/main/test/codigo-QR.png?raw=true)
58
+
59
+
60
+ ### Overview
61
+
62
+ You need obtain your own credentials with Amazon that may include an amazon developer account and access as seller or vendor. Please view the checklist of [Amazon Ads API onboarding overview](https://advertising.amazon.com/API/docs/en-us/setting-up/overview)
63
+
64
+
65
+ ### Code Credentials
66
+ You can use your credentials as follows passing it to the client as a dict. Please review the full [documentation](https://github.com/sponsors/denisneuf) to see all posibilities to include your credentials.
67
+
68
+ ```javascript
69
+ from ad_api.api import ads_api_v1
70
+
71
+
72
+ my_credentials = dict(
73
+ refresh_token='your-refresh_token',
74
+ client_id='your-client_id',
75
+ client_secret='your-client_secret',
76
+ profile_id='your-profile_id',
77
+ )
78
+
79
+ info = {
80
+ "adProductFilter":
81
+ {
82
+ "include": [
83
+ "SPONSORED_PRODUCTS"
84
+ ]
85
+ },
86
+ "stateFilter":
87
+ {
88
+ "include": [
89
+ "ENABLED"
90
+ ]
91
+ }
92
+ }
93
+
94
+ result = ads_api_v1.Campaigns(credentials=my_credentials).query_campaigns(
95
+ body=info
96
+ )
97
+
98
+ ```
99
+
100
+ ### YAML Credentials
101
+ Use a credentials.yml file with your credentials for more convenience and manage diferent accounts or profiles. Amazon requires one profile per marketplace so it is helpful to keep all in one file and switch directly from the code, using the account.
102
+
103
+ Create a file credentials.yml
104
+
105
+ ```javascript
106
+ version: '1.0'
107
+
108
+ default:
109
+ refresh_token: 'your-refresh-token'
110
+ client_id: 'your-client-id'
111
+ client_secret: 'your-client-secret'
112
+ profile_id: 'your-profile-id'
113
+
114
+ germany:
115
+ refresh_token: 'other-refresh-token'
116
+ client_id: 'other-client-id'
117
+ client_secret: 'other-client-secret'
118
+ profile_id: 'other-profile-id'
119
+
120
+ ```
121
+
122
+ Python code
123
+
124
+ ```python
125
+ from ad_api.api import ads_api_v1
126
+
127
+ info = {
128
+ "adProductFilter":
129
+ {
130
+ "include": [
131
+ "SPONSORED_PRODUCTS"
132
+ ]
133
+ }
134
+ }
135
+
136
+ # Leave empty will use the 'default' account
137
+ result=ads_api_v1.Campaigns().query_campaigns(body=info)
138
+ # will use germany account data
139
+ result=ads_api_v1.Campaigns(account="germany").query_campaigns(body=info)
140
+ ```
141
+
142
+
143
+
144
+ ### Search path for credentials.yml
145
+
146
+ * macOS and Other Unix: `~/.config/python-ad-api`
147
+ * Windows: `%APPDATA%\python-ad-api` where the <cite>APPDATA</cite> environment variable falls
148
+ back to `%HOME%\AppData\Roaming` if undefined
149
+
150
+
151
+ [Confuse Help](https://confuse.readthedocs.io/en/latest/usage.html#search-paths)
152
+
153
+
154
+ ### Marketplaces
155
+
156
+ Marketplaces are used to define basically the [API endpoints](https://advertising.amazon.com/API/docs/en-us/info/api-overview#api-endpoints) Amazon need to use depending on the regions, by default it will use EU so if you are using one of the marketplaces that are under the Europe (EU). Covers UK, FR, IT, ES, DE, NL, AE, SE, PL, and TR marketplaces you can skip. If you are using either North America (NA) or Far East (FE), you will need import from base and pass the marketplace as follows:
157
+
158
+ ```python
159
+ from ad_api.api import ads_api_v1
160
+ from ad_api.base import Marketplaces
161
+
162
+ info = {
163
+ "adProductFilter":
164
+ {
165
+ "include": [
166
+ "SPONSORED_PRODUCTS"
167
+ ]
168
+ }
169
+ }
170
+
171
+ # You can pass NA or US, CA, MX or BR for North America and JP, AU or SG for Far East
172
+ result=ads_api_v1.Campaigns(marketplace=Marketplaces.NA).query_campaigns(body=info)
173
+
174
+ ```
175
+
176
+ ### Exceptions
177
+
178
+ You can use a [try](https://docs.python.org/3.10/reference/compound_stmts.html#try) except statement when you call the API and catch exceptions if some problem ocurred:
179
+
180
+ ```python
181
+ from ad_api.api import ads_api_v1
182
+ from ad_api.base import AdvertisingApiException
183
+
184
+ info = {
185
+ "adProductFilter":
186
+ {
187
+ "include": [
188
+ "SPONSORED_PRODUCTS"
189
+ ]
190
+ },
191
+ "stateFilter":
192
+ {
193
+ "include": [
194
+ "ENABLED"
195
+ ]
196
+ }
197
+ }
198
+
199
+ try:
200
+
201
+ result = ads_api_v1.Campaigns().query_campaigns(
202
+ body=info
203
+ )
204
+
205
+ logging.info(result)
206
+
207
+ except AdvertisingApiException as error:
208
+ logging.info(error)
209
+ ```
210
+
211
+ ### Debug
212
+
213
+ Use debug=True if you want see some logs like the header you submit to the api endpoint, the method and path used among the params and the data submitted if any, to trace some possible errors. Note that the header includes the Authorization bearer token, so do not leave debug output in shared logs.
214
+
215
+ ```python
216
+ from ad_api.api import ads_api_v1
217
+ from ad_api.base import AdvertisingApiException
218
+
219
+
220
+ info = {
221
+ "adProductFilter":
222
+ {
223
+ "include": [
224
+ "SPONSORED_PRODUCTS"
225
+ ]
226
+ },
227
+ "stateFilter":
228
+ {
229
+ "include": [
230
+ "ENABLED"
231
+ ]
232
+ }
233
+ }
234
+
235
+ try:
236
+
237
+ result = ads_api_v1.Campaigns(debug=True).query_campaigns(
238
+ body=info
239
+ )
240
+
241
+ logging.info(result)
242
+
243
+ except AdvertisingApiException as error:
244
+ logging.info(error)
245
+ ```
246
+
247
+
248
+ ### Migrating from 1.x
249
+
250
+ `ad_api.api.Invoices` no longer exists. Amazon serves `/invoices` and
251
+ `/invoices/{invoiceId}` from the same contract as the rest of billing, so both
252
+ methods moved to `Billing`:
253
+
254
+ ```python
255
+ # before
256
+ from ad_api.api import Invoices
257
+ Invoices(account=store).list_invoices()
258
+
259
+ # now
260
+ from ad_api.api import Billing
261
+ Billing(account=store).list_invoices()
262
+ ```
263
+
264
+ ### What is covered
265
+
266
+ Every Amazon Ads API family this package speaks to, and how many modules it
267
+ ships. The per-module detail, with the contract and the vendor page of each
268
+ one, lives in the documentation:
269
+
270
+ **[python-amazon-ad-api.readthedocs.io](https://python-amazon-ad-api.readthedocs.io/en/latest/)**
271
+
272
+ | Family | Modules | Docs |
273
+ |---|---|---|
274
+ | Amazon Ads API v0 | 30 | [v0](https://python-amazon-ad-api.readthedocs.io/en/latest/v0.html) |
275
+ | Amazon Ads API v1 | 19 | [v1](https://python-amazon-ad-api.readthedocs.io/en/latest/v1.html) |
276
+
277
+ Coverage against the whole vendor tree, entries implemented and pending, is on
278
+ [Coverage](https://python-amazon-ad-api.readthedocs.io/en/latest/v0/not_implemented.html)
279
+ and the tree itself on
280
+ [Full Vendor tree](https://python-amazon-ad-api.readthedocs.io/en/latest/v0/full_vendor_tree.html).
281
+
282
+ ### Amazon Ads API v1 - basic example
283
+
284
+ Both `v1` and `ads_api_v1` name the same namespace, so pick whichever reads
285
+ clearer: `from ad_api.api import v1` is shorter, and `ads_api_v1` makes it
286
+ obvious at the call site that the v1 API is being used.
287
+
288
+ ```python
289
+ from ad_api.api import v1
290
+
291
+ result = v1.Campaigns(credentials=credentials, debug=True).query_campaigns(
292
+ body={
293
+ "adProductFilter": {"include": ["SPONSORED_PRODUCTS"]},
294
+ "stateFilter": {"include": ["ENABLED"]},
295
+ "maxResults": 100,
296
+ }
297
+ )
298
+
299
+ campaigns = result.payload.get("campaigns")
300
+ next_token = result.payload.get("nextToken")
301
+ ```
302
+
303
+ ### Simple Example Usage Campaigns with Credentials (v3, legacy)
304
+
305
+ > This example uses `CampaignsV3.list_campaigns`, which is deprecated. See the v1 `query_campaigns` example above.
306
+
307
+ ```python
308
+ import logging
309
+ from ad_api.base import AdvertisingApiException
310
+ from ad_api.api import sponsored_products
311
+
312
+ logging.basicConfig(
313
+ level=logging.DEBUG,
314
+ format="%(asctime)s:%(levelname)s:%(message)s"
315
+ )
316
+
317
+ def sp_list_campaigns_v3(info: dict = None):
318
+
319
+ credentials = dict(
320
+ refresh_token='your-refresh_token',
321
+ client_id='your-client_id',
322
+ client_secret='your-client_secret',
323
+ profile_id='your-profile_id',
324
+ )
325
+
326
+ try:
327
+ result = sponsored_products.CampaignsV3(credentials=credentials, debug=True).list_campaigns(
328
+ body=info
329
+ )
330
+ payload = result.payload
331
+ return payload
332
+ except AdvertisingApiException as error:
333
+ logging.error(error)
334
+ logging.error(error.code)
335
+
336
+
337
+ state_filter = \
338
+ {
339
+ "stateFilter":
340
+ {
341
+ "include": [
342
+ "ENABLED"
343
+ ]
344
+ }
345
+ }
346
+
347
+ enabled_campaigns = sp_list_campaigns_v3(state_filter).get("campaigns")
348
+
349
+
350
+ for campaign in enabled_campaigns:
351
+ logging.info(campaign)
352
+
353
+ logging.info(len(campaigns))
354
+
355
+
356
+
357
+ ```
358
+
359
+ ### API NOTICE
360
+
361
+ This API is based on the [API Client](https://github.com/saleweaver/rapid_rest_client) created by [@saleweaver](https://github.com/saleweaver) but adapted to amazon advertising authentication requeriments
362
+
363
+ ### DISCLAIMER
364
+
365
+ We are not affiliated with Amazon but they used our api :)
366
+
367
+ ### LICENSE
368
+
369
+ ![License](https://img.shields.io/badge/license-MIT-green)
370
+
371
+
372
+ ---
373
+ *Last release: v2.2.3*
@@ -1,6 +1,6 @@
1
1
  ad_api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- ad_api/version.py,sha256=toAYzE_ok1SiBE0AqAVdW0O8YCXCwcx0w4JATYQuJOg,22
3
- ad_api/api/__init__.py,sha256=4p60tAyAZYdSfxNrMQ1IA4vSPVhq9lNH_riZscD-99c,2028
2
+ ad_api/version.py,sha256=7vcEgCSkbhT9Gg0A1zz0ATFhMnUIE2MAurmV3fHzG8g,22
3
+ ad_api/api/__init__.py,sha256=MS9URuCMvZ7c4T2OOWhJg-ovgZHGaxa8wXruPMqRqlc,2079
4
4
  ad_api/api/account.py,sha256=jNYwfjW8b0HhqP7PjlMev55aXJP3YIuqWhrxri0Pk4Y,4673
5
5
  ad_api/api/account_budgets.py,sha256=jFce5eLWAFK3ydjnYR7_Sv7B0-gHTG5bMTx_TcHyy1A,2319
6
6
  ad_api/api/advertising_invitations.py,sha256=TRwULEFi_HVyfK35ABkuZbFOHAdl4tNnGWanxrvX32A,4629
@@ -10,6 +10,7 @@ ad_api/api/attribution.py,sha256=N7aspRbaVK7y8Q1OZ0P9O3CP7gwnS_NzhmNchISFQAI,748
10
10
  ad_api/api/audiences.py,sha256=WuOmHtXyzF1KUXiE9FayXLvb1GI9Q6Z1Y25G2bA-mjc,3575
11
11
  ad_api/api/billing.py,sha256=C_lFVdnymX3V9bg865Bf5f5DMm31IROxvJNYPhvoR7c,29322
12
12
  ad_api/api/brand_benchmarks.py,sha256=ht5EMvGeIb7MA8U2HfQtOj818T6JxM9nEY_HtsBo2H0,3280
13
+ ad_api/api/brand_home.py,sha256=snR-PFT_6NkL_FH_N8liz7Os7DP1I051930pRTzUwvA,5730
13
14
  ad_api/api/brand_metrics.py,sha256=zEOSPffq8j-2vAz_z77EcKU2sa9i1WzzBqswTmoL5yA,9321
14
15
  ad_api/api/creative_assets.py,sha256=u0bCnioUFpGOQO5Z_MO0ErSLcAgSZB5GWM5wm2oW6L0,9687
15
16
  ad_api/api/dsp_advertiser.py,sha256=ztSr0s15Z9scQNKElWxRujexsENn84MT-ihNhijLi_M,1427
@@ -96,6 +97,16 @@ ad_api/api/sp/product_targeting_v3.py,sha256=vk_T0piHzP5uwt8HSHm5hFKP_0sXJD8nbyo
96
97
  ad_api/api/sp/ranked_keywords_recommendations.py,sha256=QYFje19TFmwhedh7sn5VJIypL8gp6d6tpBQCpf_SIXw,13094
97
98
  ad_api/api/sp/schedule_based_bid_optimization.py,sha256=G8VkS7iP1lTIAxZgbfRCLz8njw1DkVH9HQPOZ63pWNU,2371
98
99
  ad_api/api/sp/target_promotion_groups.py,sha256=g5QbnFFRvzKdmS9blrD9IJcHtq2RtT9CzKlx_WWJd6s,6127
100
+ ad_api/api/st/__init__.py,sha256=4nicqoMt_HavmYlJ3rJfieHgU9sJc8owcmi7720YxW8,495
101
+ ad_api/api/st/ad_groups.py,sha256=nKi5bAKhbyKKTORG119zrcsl_B1tK5wTo0f5YdxMe8E,6032
102
+ ad_api/api/st/ads.py,sha256=ElRoryHmbdn87Q5v8QYOIID4muOdEk-1MB5bM5Q2Gsw,4693
103
+ ad_api/api/st/campaigns.py,sha256=78OPUwQNfMyVMJvNA5NcltufhjKcfj0IjwwLvwFb7Hg,4954
104
+ ad_api/api/st/creatives.py,sha256=DqaAULstUPh-GgmBPT2hEsSpFafb69H8lADJsqWrBXU,3129
105
+ ad_api/api/st/creatives_moderations.py,sha256=q6GDnW_vyAlON6iCmpQsAY901ws31zv0KVtzGkBDyw4,2566
106
+ ad_api/api/st/creatives_preview.py,sha256=YGZrj2a40Dp70nxyHZgUylTug69YqtIzgwrwiMGIjV4,1434
107
+ ad_api/api/st/forecasts.py,sha256=hRnCZUeBm0dwaTUWATgMBsRyxcVG1haoSbgan1meSTc,1311
108
+ ad_api/api/st/locations.py,sha256=hKCi8iEbe-xtXuAqNi2NrNNkUUiUdCfPAQyrZXtR46U,3175
109
+ ad_api/api/st/targets.py,sha256=FDzFd2MnyYNEoQ_6mQPbk_bc9BKFJm6lxHBaQS5zg7w,5023
99
110
  ad_api/api/v1/__init__.py,sha256=K7rmsKJnWebiarPZknUIcXJKvoIDPI5dBVNrIJGWa2I,1370
100
111
  ad_api/api/v1/ad_associations.py,sha256=2pDeqdXmx_EXb-y7Ktiq88lpvnTrmJgpjnMPSuONnmI,7524
101
112
  ad_api/api/v1/ad_extensions.py,sha256=20b8yR9UI3zeF63_xqg_rnj1qYyx2kslsDYgEx_GaB8,6619
@@ -134,8 +145,8 @@ ad_api/base/marketplaces.py,sha256=44lvCcluXNpqTprWQ80e3weSQmQbJoWL-WDSOWVbCyQ,4
134
145
  ad_api/base/utils.py,sha256=_qnCBOvyJTLgaZjJzUWTi38GGLHkQszXELs79133Rb4,5618
135
146
  ad_api/shared/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
136
147
  ad_api/shared/base_client.py,sha256=zOL_LTh-58URWf3ZDlrwmqXXbd6PX66QF5hrr2p83yY,356
137
- python_amazon_ad_api-2.2.2.dist-info/licenses/LICENSE,sha256=h2rpqlmmLy-4l1tN6KpWAFxx1JEMYeEFrMrZUbx_B_o,1105
138
- python_amazon_ad_api-2.2.2.dist-info/METADATA,sha256=RR-8K0mFMpqRjzJLJcPZYXY83GoHX3Qjaus1hXTh5P8,54257
139
- python_amazon_ad_api-2.2.2.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
140
- python_amazon_ad_api-2.2.2.dist-info/top_level.txt,sha256=nN9twUos-8pkP514ZwpvRU9YL9L2XyQyHsMQFfudGTU,7
141
- python_amazon_ad_api-2.2.2.dist-info/RECORD,,
148
+ python_amazon_ad_api-2.2.4.dist-info/licenses/LICENSE,sha256=h2rpqlmmLy-4l1tN6KpWAFxx1JEMYeEFrMrZUbx_B_o,1105
149
+ python_amazon_ad_api-2.2.4.dist-info/METADATA,sha256=4LuqczC5B4BLwABm3At8dVNOznLmGRV1mMzwpPccfHg,10678
150
+ python_amazon_ad_api-2.2.4.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
151
+ python_amazon_ad_api-2.2.4.dist-info/top_level.txt,sha256=nN9twUos-8pkP514ZwpvRU9YL9L2XyQyHsMQFfudGTU,7
152
+ python_amazon_ad_api-2.2.4.dist-info/RECORD,,