-
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
428 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
class Profiles(Client): | ||
""" | ||
Profiles AD-API Client | ||
:link: | ||
:link: | ||
With the Profiles. | ||
""" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from .campaigns import Campaigns | ||
__all__ = [ | ||
"Campaigns" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from ad_api.base import Client, sp_endpoint, fill_query_params, ApiResponse | ||
|
||
class Campaigns(Client): | ||
|
||
@sp_endpoint('/v2/sd/campaigns', method='GET') | ||
def list_campaigns(self, **kwargs) -> ApiResponse: | ||
r""" | ||
list_campaigns(self, **kwargs) -> ApiResponse | ||
Gets an array of campaigns. | ||
query **startIndex**:*integer* | Optional. 0-indexed record offset for the result set. Default value : 0 | ||
query **count**:*integer* | Optional. Number of records to include in the paged response. Defaults to max page size. | ||
query **stateFilter**:*string* | Optional. The returned array is filtered to include only ad groups with state set to one of the values in the specified comma-delimited list. Available values : enabled, paused, archived, enabled, paused, enabled, archived, paused, archived, enabled, paused, archived Default value : enabled, paused, archived. | ||
query **name**:*string* | Optional. Restricts results to campaigns with the specified name. | ||
query **portfolioIdFilter**:*string* | Optional. A comma-delimited list of portfolio identifiers. | ||
query **campaignIdFilter**:*string* | Optional. A comma-delimited list of campaign identifiers. | ||
Returns: | ||
ApiResponse | ||
""" | ||
return self._request(kwargs.pop('path'), params=kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,59 @@ | ||
from ad_api.base import Client, sp_endpoint, fill_query_params, ApiResponse | ||
|
||
class Reports(Client): | ||
|
||
""" | ||
Use the Amazon Advertising API for Sponsored Products for campaign, ad group, keyword, negative keyword, and product ad management operations. For more information about Sponsored Products, see the Sponsored Products Support Center. For onboarding information, see the account setup topic. | ||
""" | ||
@sp_endpoint('/v2/sp/{}/report', method='POST') | ||
def post_report(self, recordType, **kwargs) -> ApiResponse: | ||
r""" | ||
Requests a Sponsored Products report. | ||
Request the creation of a performance report for all entities of a single type which have performance data to report. Record types can be one of campaigns, adGroups, keywords, productAds, asins, and targets. Note that for asin reports, the report currently can not include metrics associated with both keywords and targets. If the targetingId value is set in the request, the report filters on targets and does not return sales associated with keywords. If the targetingId value is not set in the request, the report filters on keywords and does not return sales associated with targets. Therefore, the default behavior filters the report on keywords. Also note that if both keywordId and targetingId values are passed, the report filters on targets only and does not return keywords. | ||
Keyword Args | ||
| path **recordType** (integer): The type of entity for which the report should be generated. Available values : campaigns, adGroups, keywords, productAds, asins, targets [required] | ||
Request body | ||
| **stateFilter** (string): [optional] Filters the response to include reports with state set to one of the values in the comma-delimited list. Note that this filter is only valid for reports of the following type and segment. Asins and targets report types are not supported. Enum [ enabled, paused, archived ]. | ||
| **campaignType** (list > string): [required] Enum: The type of campaign. Only required for asins report - don't use with other report types. [sponsoredProducts] | ||
| **segment** (string) Dimension on which the report is segmented. Note that Search-terms report for auto-targeted campaigns created before 11/14/2018 can be accessed from the /v2/sp/keywords/report resource. Search-terms report for auto-targeted campaigns generated on-and-after 11/14/2018 can be accessed from the /v2/sp/targets/report resource. Also, keyword search terms reports only return search terms that have generated at least one click or one sale. Enum [ query, placement ]. | ||
| **reportDate** (string): [optional] The date for which to retrieve the performance report in YYYYMMDD format. The time zone is specified by the profile used to request the report. If this date is today, then the performance report may contain partial information. Reports are not available for data older than 60 days. For details on data latency, see the Service Guarantees in the developer notes section. | ||
| **metrics** (string) [optional] A comma-separated list of the metrics to be included in the report. The following tables summarize report metrics which can be requested via the reports interface. Different report types can use different metrics. Note that ASIN reports only return data for either keywords or targets, but not both. | ||
Returns: | ||
ApiResponse | ||
""" | ||
return self._request(fill_query_params(kwargs.pop('path'), recordType), data=kwargs.pop('body'), params=kwargs) | ||
|
||
@sp_endpoint('/v2/report/{}', method='GET') | ||
@sp_endpoint('/v2/reports/{}', method='GET') | ||
def get_report(self, reportId, **kwargs) -> ApiResponse: | ||
r""" | ||
Gets a previously requested report specified by identifier. | ||
Keyword Args | ||
| path **reportId** (number): The report identifier. [required] | ||
Returns: | ||
ApiResponse | ||
""" | ||
return self._request(fill_query_params(kwargs.pop('path'), reportId), params=kwargs) | ||
|
||
def download_report(self, **kwargs) -> ApiResponse: | ||
r""" | ||
Downloads the report previously get report specified by location (this is not part of the official Amazon Advertising API, is a helper method to download the report). Take in mind that a direct download of location returned in get_report will return 401 - Unauthorized. | ||
kwarg parameter **file** if not provided will take the default amazon name from path download (add a path with slash / if you want a specific folder, do not add extension as the return will provide the right extension based on format choosed if needed) | ||
kwarg parameter **format** if not provided a format will return a url to download the report (this url has a expiration time) | ||
Keyword Args | ||
| **url** (string): The location obatined from get_report [required] | ||
| **file** (string): The path to save the file if mode is download json, zip or gzip. [optional] | ||
| **format** (string): The mode to download the report: data (list), raw, url, json, zip, gzip. Default (url) [optional] | ||
Returns: | ||
ApiResponse | ||
""" | ||
return self._download(self, params=kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,52 @@ | ||
from ad_api.base import Client, sp_endpoint, fill_query_params, ApiResponse | ||
|
||
class Snapshots(Client): | ||
|
||
@sp_endpoint('/v2/sp/{}/snapshots', method='POST') | ||
""" | ||
Use the Amazon Advertising API for Sponsored Products for campaign, ad group, keyword, negative keyword, and product ad management operations. For more information about Sponsored Products, see the Sponsored Products Support Center. For onboarding information, see the account setup topic. | ||
""" | ||
@sp_endpoint('/v2/sp/{}/snapshot', method='POST') | ||
def post_snapshot(self, recordType, **kwargs) -> ApiResponse: | ||
""" | ||
Request a file-based snapshot of all entities of the specified type in the account satisfying the filtering criteria. | ||
Keyword Args | ||
| path **recordType** (integer): The type of entity for which the snapshot is generated. Available values : campaigns, adGroups, keywords, negativeKeywords, campaignNegativeKeywords, productAds, targets, negativeTargets [required] | ||
Request body | ||
| **stateFilter** (string): [required] [ enabled, paused, archived, enabled, paused, enabled, archived, paused, archived, enabled, paused, archived ]. | ||
Returns: | ||
ApiResponse | ||
""" | ||
return self._request(fill_query_params(kwargs.pop('path'), recordType), data=kwargs.pop('body'), params=kwargs) | ||
|
||
@sp_endpoint('/v2/snapshots/{}', method='GET') | ||
def get_snapshot(self, reportId, **kwargs) -> ApiResponse: | ||
return self._request(fill_query_params(kwargs.pop('path'), reportId), params=kwargs) | ||
def get_snapshot(self, snapshotId, **kwargs) -> ApiResponse: | ||
r""" | ||
Gets the status of a requested snapshot. | ||
Keyword Args | ||
| path **snapshotId** (number): The snapshot identifier. [required] | ||
Returns: | ||
ApiResponse | ||
""" | ||
return self._request(fill_query_params(kwargs.pop('path'), snapshotId), params=kwargs) | ||
|
||
def download_snapshot(self, **kwargs) -> ApiResponse: | ||
r""" | ||
Downloads the snapshot previously get report specified by location (this is not part of the official Amazon Advertising API, is a helper method to download the snapshot). Take in mind that a direct download of location returned in get_snapshot will return 401 - Unauthorized. | ||
kwarg parameter **file** if not provided will take the default amazon name from path download (add a path with slash / if you want a specific folder, do not add extension as the return will provide the right extension based on format choosed if needed) | ||
kwarg parameter **format** if not provided a format will return a url to download the snapshot (this url has a expiration time) | ||
Keyword Args | ||
| **url** (string): The location obatined from get_snapshot [required] | ||
| **file** (string): The path to save the file if mode is download json, zip or gzip. [optional] | ||
| **format** (string): The mode to download the snapshot: data (list), raw, url, json, zip, gzip. Default (url) [optional] | ||
Returns: | ||
ApiResponse | ||
""" | ||
return self._download(self, params=kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
Targets | ||
Product Targeting | ||
================= | ||
|
||
.. autoclass:: ad_api.api.sp.Targets | ||
|
Oops, something went wrong.