python-amazon-ad-api 2.2.9__py3-none-any.whl → 2.3.1__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/__init__.py +24 -0
- ad_api/api/ad_library.py +76 -0
- ad_api/api/campaign_diagnostics.py +54 -0
- ad_api/api/forecast.py +130 -0
- ad_api/api/hashed_records.py +39 -0
- ad_api/api/historic_reach.py +148 -0
- ad_api/api/locations.py +57 -0
- ad_api/api/moderation.py +65 -0
- ad_api/api/persona_builder.py +174 -0
- ad_api/api/plan_management.py +1268 -0
- ad_api/api/pre_moderation.py +64 -0
- ad_api/api/record_management.py +121 -0
- ad_api/api/targetable_entities.py +89 -0
- ad_api/version.py +1 -1
- {python_amazon_ad_api-2.2.9.dist-info → python_amazon_ad_api-2.3.1.dist-info}/METADATA +1 -1
- {python_amazon_ad_api-2.2.9.dist-info → python_amazon_ad_api-2.3.1.dist-info}/RECORD +19 -7
- {python_amazon_ad_api-2.2.9.dist-info → python_amazon_ad_api-2.3.1.dist-info}/WHEEL +0 -0
- {python_amazon_ad_api-2.2.9.dist-info → python_amazon_ad_api-2.3.1.dist-info}/licenses/LICENSE +0 -0
- {python_amazon_ad_api-2.2.9.dist-info → python_amazon_ad_api-2.3.1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"""Persona Builder API /insights.
|
|
2
|
+
|
|
3
|
+
Contract: Persona Builder API 3.0. Five routes, all of them ``POST`` and all of
|
|
4
|
+
them under ``/insights``. Each one takes an audience expression, a persona, and
|
|
5
|
+
returns aggregated insights for it. An advertiser can then save that expression
|
|
6
|
+
to DSP as a combined audience.
|
|
7
|
+
|
|
8
|
+
The parent is *Recommendations & insights*, next to *Partner opportunities* and
|
|
9
|
+
*Overlapping audiences*.
|
|
10
|
+
|
|
11
|
+
Every route has its **own pair** of media types: the request body one names the
|
|
12
|
+
input expression and the response one names the insights. They are not a single
|
|
13
|
+
``vnd.<family>.v<n>`` pair, so each method builds both from its own strings.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
from ad_api.base import Client, sp_endpoint, fill_query_params, ApiResponse, Utils
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class PersonaBuilder(Client):
|
|
20
|
+
r"""Persona Builder API - /insights
|
|
21
|
+
|
|
22
|
+
Documentation: https://advertising.amazon.com/API/docs/en-us/persona-builder
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
@sp_endpoint('/insights/bandedSize', method='POST',
|
|
26
|
+
headers=['Amazon-Advertising-AccountId'])
|
|
27
|
+
def post_banded_size(self, version: int = 1, **kwargs) -> ApiResponse:
|
|
28
|
+
r"""
|
|
29
|
+
Gets the banded size of the number of unique customers inside the expression.
|
|
30
|
+
Read only.
|
|
31
|
+
|
|
32
|
+
Request Body [Required]
|
|
33
|
+
| **audienceTargetingExpression** (dict): the persona, groups of
|
|
34
|
+
| audiences joined by an intersection and each group by a union.
|
|
35
|
+
| Up to 10 included groups, only 1 excluded, up to 500 ids per group.
|
|
36
|
+
| **countryCodes** (list): ISO alpha-2, one country per request. It
|
|
37
|
+
| is required when the advertiser has no associated country.
|
|
38
|
+
|
|
39
|
+
Keyword Args
|
|
40
|
+
|
|
41
|
+
- ``advertiserId`` (str): the advertiser, from ``/dsp/advertisers``. [required]
|
|
42
|
+
- ``version`` (int): media type version. Defaults to 1. [optional]
|
|
43
|
+
|
|
44
|
+
Returns
|
|
45
|
+
ApiResponse with ``estimatedSize`` (``min`` and ``max``) and ``lastUpdatedAt``.
|
|
46
|
+
"""
|
|
47
|
+
request_type = 'application/vnd.bandedsizeinputexpression.v' + str(version) + '+json'
|
|
48
|
+
accept = 'application/vnd.bandedsizeinsights.v' + str(version) + '+json'
|
|
49
|
+
headers = {'Accept': accept, 'Content-Type': request_type}
|
|
50
|
+
body = Utils.convert_body(kwargs.pop('body'), False)
|
|
51
|
+
return self._request(fill_query_params(kwargs.pop('path')),
|
|
52
|
+
data=body, params=kwargs, headers=headers)
|
|
53
|
+
|
|
54
|
+
@sp_endpoint('/insights/demographics', method='POST',
|
|
55
|
+
headers=['Amazon-Advertising-AccountId'])
|
|
56
|
+
def post_demographics(self, version: int = 1, **kwargs) -> ApiResponse:
|
|
57
|
+
r"""
|
|
58
|
+
Gets the demographic composition of the customers inside the expression.
|
|
59
|
+
Read only.
|
|
60
|
+
|
|
61
|
+
Request Body [Required]
|
|
62
|
+
| **audienceTargetingExpression** (dict): the persona, groups of
|
|
63
|
+
| audiences joined by an intersection and each group by a union.
|
|
64
|
+
| Up to 10 included groups, only 1 excluded, up to 500 ids per group.
|
|
65
|
+
| **countryCodes** (list): ISO alpha-2, one country per request. It
|
|
66
|
+
| is required when the advertiser has no associated country.
|
|
67
|
+
|
|
68
|
+
Keyword Args
|
|
69
|
+
|
|
70
|
+
- ``advertiserId`` (str): the advertiser, from ``/dsp/advertisers``. [required]
|
|
71
|
+
- ``version`` (int): media type version. Defaults to 1. [optional]
|
|
72
|
+
|
|
73
|
+
Returns
|
|
74
|
+
ApiResponse with the age ranges, education, gender, income and the rest of ``DemographicsResponseContent``.
|
|
75
|
+
"""
|
|
76
|
+
request_type = 'application/vnd.demographicinputexpressions.v' + str(version) + '+json'
|
|
77
|
+
accept = 'application/vnd.demographicinsights.v' + str(version) + '+json'
|
|
78
|
+
headers = {'Accept': accept, 'Content-Type': request_type}
|
|
79
|
+
body = Utils.convert_body(kwargs.pop('body'), False)
|
|
80
|
+
return self._request(fill_query_params(kwargs.pop('path')),
|
|
81
|
+
data=body, params=kwargs, headers=headers)
|
|
82
|
+
|
|
83
|
+
@sp_endpoint('/insights/primeVideo', method='POST',
|
|
84
|
+
headers=['Amazon-Advertising-AccountId'])
|
|
85
|
+
def post_prime_video(self, version: int = 1, **kwargs) -> ApiResponse:
|
|
86
|
+
r"""
|
|
87
|
+
Gets the Prime Video consumption of the customers inside the expression: genres, actors and directors.
|
|
88
|
+
Read only.
|
|
89
|
+
|
|
90
|
+
Request Body [Required]
|
|
91
|
+
| **audienceTargetingExpression** (dict): the persona, groups of
|
|
92
|
+
| audiences joined by an intersection and each group by a union.
|
|
93
|
+
| Up to 10 included groups, only 1 excluded, up to 500 ids per group.
|
|
94
|
+
| **countryCodes** (list): ISO alpha-2, one country per request. It
|
|
95
|
+
| is required when the advertiser has no associated country.
|
|
96
|
+
|
|
97
|
+
Keyword Args
|
|
98
|
+
|
|
99
|
+
- ``advertiserId`` (str): the advertiser, from ``/dsp/advertisers``. [required]
|
|
100
|
+
- ``version`` (int): media type version. Defaults to 1. [optional]
|
|
101
|
+
|
|
102
|
+
Returns
|
|
103
|
+
ApiResponse with ``PrimeVideoResponseContent``.
|
|
104
|
+
"""
|
|
105
|
+
request_type = 'application/vnd.primevideoinputexpressions.v' + str(version) + '+json'
|
|
106
|
+
accept = 'application/vnd.primevideoinsights.v' + str(version) + '+json'
|
|
107
|
+
headers = {'Accept': accept, 'Content-Type': request_type}
|
|
108
|
+
body = Utils.convert_body(kwargs.pop('body'), False)
|
|
109
|
+
return self._request(fill_query_params(kwargs.pop('path')),
|
|
110
|
+
data=body, params=kwargs, headers=headers)
|
|
111
|
+
|
|
112
|
+
@sp_endpoint('/insights/topCategoriesPurchased', method='POST',
|
|
113
|
+
headers=['Amazon-Advertising-AccountId'])
|
|
114
|
+
def post_top_categories_purchased(self, version: int = 1, **kwargs) -> ApiResponse:
|
|
115
|
+
r"""
|
|
116
|
+
Gets the product categories the customers inside the expression buy the most, with pagination.
|
|
117
|
+
Read only.
|
|
118
|
+
|
|
119
|
+
Request Body [Required]
|
|
120
|
+
| **audienceTargetingExpression** (dict): the persona, groups of
|
|
121
|
+
| audiences joined by an intersection and each group by a union.
|
|
122
|
+
| Up to 10 included groups, only 1 excluded, up to 500 ids per group.
|
|
123
|
+
| **countryCodes** (list): ISO alpha-2, one country per request. It
|
|
124
|
+
| is required when the advertiser has no associated country.
|
|
125
|
+
|
|
126
|
+
Keyword Args
|
|
127
|
+
|
|
128
|
+
- ``advertiserId`` (str): the advertiser, from ``/dsp/advertisers``. [required]
|
|
129
|
+
|
|
130
|
+
- ``maxResults`` (int): page size. [optional]
|
|
131
|
+
- ``nextToken`` (str): token from a previous answer. [optional]
|
|
132
|
+
- ``version`` (int): media type version. Defaults to 1. [optional]
|
|
133
|
+
|
|
134
|
+
Returns
|
|
135
|
+
ApiResponse with the ranked categories and ``nextToken``.
|
|
136
|
+
"""
|
|
137
|
+
request_type = 'application/vnd.topcategoriespurchasedinputexpression.v' + str(version) + '+json'
|
|
138
|
+
accept = 'application/vnd.topcategoriespurchasedinsights.v' + str(version) + '+json'
|
|
139
|
+
headers = {'Accept': accept, 'Content-Type': request_type}
|
|
140
|
+
body = Utils.convert_body(kwargs.pop('body'), False)
|
|
141
|
+
return self._request(fill_query_params(kwargs.pop('path')),
|
|
142
|
+
data=body, params=kwargs, headers=headers)
|
|
143
|
+
|
|
144
|
+
@sp_endpoint('/insights/topOverlappingAudiences', method='POST',
|
|
145
|
+
headers=['Amazon-Advertising-AccountId'])
|
|
146
|
+
def post_top_overlapping_audiences(self, version: int = 1, **kwargs) -> ApiResponse:
|
|
147
|
+
r"""
|
|
148
|
+
Gets the audiences that overlap the expression the most, ranked by affinity, with pagination.
|
|
149
|
+
Read only.
|
|
150
|
+
|
|
151
|
+
Request Body [Required]
|
|
152
|
+
| **audienceTargetingExpression** (dict): the persona, groups of
|
|
153
|
+
| audiences joined by an intersection and each group by a union.
|
|
154
|
+
| Up to 10 included groups, only 1 excluded, up to 500 ids per group.
|
|
155
|
+
| **countryCodes** (list): ISO alpha-2, one country per request. It
|
|
156
|
+
| is required when the advertiser has no associated country.
|
|
157
|
+
|
|
158
|
+
Keyword Args
|
|
159
|
+
|
|
160
|
+
- ``advertiserId`` (str): the advertiser, from ``/dsp/advertisers``. [required]
|
|
161
|
+
|
|
162
|
+
- ``maxResults`` (int): page size. [optional]
|
|
163
|
+
- ``nextToken`` (str): token from a previous answer. [optional]
|
|
164
|
+
- ``version`` (int): media type version. Defaults to 1. [optional]
|
|
165
|
+
|
|
166
|
+
Returns
|
|
167
|
+
ApiResponse with the overlapping audiences and ``nextToken``.
|
|
168
|
+
"""
|
|
169
|
+
request_type = 'application/vnd.topoverlappingaudiencesinputexpression.v' + str(version) + '+json'
|
|
170
|
+
accept = 'application/vnd.topoverlappingaudiencesinsights.v' + str(version) + '+json'
|
|
171
|
+
headers = {'Accept': accept, 'Content-Type': request_type}
|
|
172
|
+
body = Utils.convert_body(kwargs.pop('body'), False)
|
|
173
|
+
return self._request(fill_query_params(kwargs.pop('path')),
|
|
174
|
+
data=body, params=kwargs, headers=headers)
|