post_report

BrandMetrics.post_report(**kwargs) → ApiResponse

Requests a Brand Metrics report.

Asks the service to generate the report; the answer is a handle, not the data. It carries a reportId, a status and an empty location, and the report is produced asynchronously. Pass the reportId to get_report() until status reads SUCCESSFUL, then download location.

Generates the Brand Metrics report in CSV or JSON format. Customize the report by passing a specific categoryTreeName, categoryPath, brandName, reportStartDate, reportEndDate, lookBackPeriod, format or a list of metrics from the available metrics in the metrics field. If an empty request body is passed, report for the latest available report date in JSON format will get generated with all the available brands and metrics for an advertiser. The report may or may not contain the Brand Metrics data for one or more brands depending on data availability.

Every field is optional. An empty body generates the latest available report in JSON with every brand and metric on the account.

Request body
categoryTreeName (string): [optional] The node at the top of a browse tree. It is the start node of a tree. example: us-home
categoryPath (array of arrays): [optional] The hierarchical path that leads to a node starting with the root node, as a list of paths where each path is a list of levels. If no category path is passed, then all data available for all brands belonging to the entity are retrieved. example: [ [“Categories”, “Granola & Snack Bars”, “Snack Food”] ]
brandName (string): [optional] Brand Name. If no Brand Name is passed, then all data available for all brands belonging to the entity are retrieved. example: Mattress Mogul
reportStartDate (string($date)): [optional] Retrieves metrics with metricsComputationDate between reportStartDate and reportEndDate (inclusive). The date will be in the Coordinated Universal Time (UTC) timezone in YYYY-MM-DD format. If no date is passed in reportStartDate, all available metrics with metricsComputationDate till the reportEndDate will be provided. If no date is passed for either reportStartDate or reportEndDate, the metrics with the most receont metricsComputationDate will be returned. example: 2021-01-01
lookBackPeriod (string) [optional] Currently supported values: “1W” (one week), “1M” (one month) and “1CM” (one calendar month), which is the enum the v1 contract declares; the v1.1 contract declares the lower case forms and the service accepted both. This defines the period of time used to determine the number of shoppers in the metrics computation. default: 1w
format (string) [optional] Format of the report. [ JSON, CSV ]. default: JSON
metrics (list) [optional] Specify an array of string of metrics field names to include in the report. If no metric field names are specified, all metrics are returned.
reportEndDate (string($date)) [optional] Retrieves metrics with metricsComputationDate between reportStartDate and reportEndDate (inclusive). The date will be in the Coordinated Universal Time (UTC) timezone in YYYY-MM-DD format. If no date is passed in reportEndDate, all available metrics with metricsComputationDate from the reportStartDate will be provided. If no date is passed for either reportStartDate or reportEndDate, the metrics with the most receont metricsComputationDate will be returned. example: 2021-01-30

The contract names the two category fields categoryTreeName and categoryPath, while the answers come back carrying categoryNodeTreeName and categoryNodeName. Neither spelling filters: both were sent with different values, and a tree name that does not exist (zz-no-existe-zz) was answered with the account’s full set exactly like a real one. Send the contract names, but do not expect them to narrow the report – filter on brandName and the date range instead, which are the fields the service was seen to honour.

Returns:

  • reportId (string): the handle for get_report().

  • status (string): IN_PROGRESS on a fresh request.

  • statusDetails (string): a sentence describing that status.

  • expiration (integer): how long the result stays available.

  • format (string): echoes the requested format.

  • location (string): empty until the report is ready.

Return type:

ApiResponse. payload holds

Example:

from ad_api.api import BrandMetrics

bm = BrandMetrics(account="my_account")
bm.post_report(body={"format": "JSON", "lookBackPeriod": "1w"}).payload
# {'reportId': '8d3e7143-...', 'status': 'IN_PROGRESS',
#  'statusDetails': 'Generation of the report is in progress!',
#  'expiration': 300000, 'format': 'JSON', 'location': ''}