Skip to content

Commit 9c4a7f6

Browse files
committed
feat(sb): Add support for Sponsored Brands theme targeting
This commit introduces the `Themes` class to manage theme-based targeting for Sponsored Brands campaigns. Theme targeting automatically targets keywords related to a brand or landing pages. This new functionality includes the ability to: - Create, retrieve, update, and archive theme targets. - List themes with filtering options. - Enable and pause themes using convenience methods.
1 parent 5ef7236 commit 9c4a7f6

File tree

2 files changed

+82
-1
lines changed

2 files changed

+82
-1
lines changed

ad_api/api/sb/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
from .reports import Reports
2222
from .snapshots import Snapshots
2323
from .benchmarks import Benchmarks
24+
from .themes import Themes
2425

2526
__all__ = [
2627
"Brands",
@@ -45,5 +46,6 @@
4546
"Media",
4647
"Reports",
4748
"Snapshots",
48-
"Benchmarks"
49+
"Benchmarks",
50+
"Themes"
4951
]

ad_api/api/sb/themes.py

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
from ad_api.base import Client, sp_endpoint, ApiResponse, Utils
2+
3+
4+
class Themes(Client):
5+
"""
6+
Amazon Ads API - Sponsored Brands - Theme Targeting
7+
8+
Theme targeting automatically targets keywords related to your brand or landing pages.
9+
"""
10+
11+
@sp_endpoint('/sb/themes/list', method='POST')
12+
def list_themes(self, **kwargs) -> ApiResponse:
13+
r"""
14+
Gets a list of theme targets associated with the client identifier, filtered by specified criteria.
15+
16+
Request Body
17+
| '**nextToken**': *string*, {'description': 'Token for pagination. Operations that return paginated results include a pagination token in this field.'}
18+
| '**maxResults**': *number*, {'description': 'Maximum number of results to return. Defaults to API maximum.'}
19+
| '**campaignIdFilter**': *object*, {'description': 'List of campaign identifiers to filter by (max 100).'}
20+
| '**adGroupIdFilter**': *object*, {'description': 'List of ad group identifiers to filter by (max 100).'}
21+
| '**themeIdFilter**': *object*, {'description': 'List of theme target identifiers to filter by (max 100).'}
22+
| '**stateFilter**': *object*, {'description': 'List of theme target states to filter by. Valid values: enabled, paused, archived. Default: enabled, paused.'}
23+
| '**themeTypeFilter**': *object*, {'description': 'List of theme types to filter by. Valid values: KEYWORDS_RELATED_TO_YOUR_BRAND, KEYWORDS_RELATED_TO_YOUR_LANDING_PAGES.'}
24+
25+
Returns:
26+
| ApiResponse
27+
"""
28+
headers = {'Accept': 'application/vnd.sbthemeslistresponse.v3+json'}
29+
body = Utils.convert_body(kwargs.pop('body'), wrap=False)
30+
return self._request(kwargs.pop('path'), data=body, params=kwargs, headers=headers)
31+
32+
@sp_endpoint('/sb/themes', method='POST')
33+
def create_themes(self, **kwargs) -> ApiResponse:
34+
r"""
35+
Create one or more theme targets.
36+
37+
Note that theme targets can be created on multi-adGroup campaigns where campaign serving status is not archived, terminated, rejected, or ended.
38+
Note that ad group state must not be archived.
39+
Note that only one target can be created for each themeType per adGroup.
40+
Note that this operation supports a maximum list size of 100 theme targets.
41+
42+
Request Body
43+
| '**themes**': *array*, {'description': 'List of theme targets to create (max 100).'}
44+
| '**adGroupId**': *string*, {'description': 'The identifier of the ad group'}
45+
| '**campaignId**': *string*, {'description': 'The identifier of the campaign'}
46+
| '**themeType**': *string*, {'description': 'Theme type', 'Enum': 'KEYWORDS_RELATED_TO_YOUR_BRAND, KEYWORDS_RELATED_TO_YOUR_LANDING_PAGES'}
47+
| '**bid**': *number*, {'description': 'The bid amount'}
48+
49+
Returns:
50+
| ApiResponse
51+
"""
52+
headers = {'Accept': 'application/vnd.sbthemescreateresponse.v3+json'}
53+
body = Utils.convert_body(kwargs.pop('body'), wrap=False)
54+
return self._request(kwargs.pop('path'), data=body, params=kwargs, headers=headers)
55+
56+
@sp_endpoint('/sb/themes', method='PUT')
57+
def update_themes(self, **kwargs) -> ApiResponse:
58+
r"""
59+
Updates one or more theme targets.
60+
61+
Note that theme targets can be updated on multi-adGroup campaigns where campaign serving status is not archived, terminated, rejected, or ended.
62+
Note that ad group state must not be archived.
63+
Note that this operation supports a maximum list size of 100 theme targets.
64+
Note that bid is only mutable when the corresponding campaign does not have any enabled optimization rule.
65+
66+
Request Body
67+
| '**themes**': *array*, {'description': 'List of theme targets to update (max 100).'}
68+
| '**themeId**': *string*, {'description': 'The identifier of the theme target'}
69+
| '**adGroupId**': *string*, {'description': 'The identifier of the ad group'}
70+
| '**campaignId**': *string*, {'description': 'The identifier of the campaign'}
71+
| '**state**': *string*, {'description': 'Theme target state', 'Enum': 'enabled, paused, archived'}
72+
| '**bid**': *number*, {'description': 'The bid amount'}
73+
74+
Returns:
75+
| ApiResponse
76+
"""
77+
headers = {'Accept': 'application/vnd.sbthemesupdateresponse.v3+json'}
78+
body = Utils.convert_body(kwargs.pop('body'), wrap=False)
79+
return self._request(kwargs.pop('path'), data=body, params=kwargs, headers=headers)

0 commit comments

Comments
 (0)