Follow the workflow below to gather the necessary data and execute the report with the Generate a report POST operation of Reporting API v2.
Gather data to execute the report
-
Run the List reports operation to get available reports. Reports are categorized by product families and reporting areas. See also Available reports.
-
Get the options of the report you want to execute. The response shows:
-
Available metrics and dimensions. For their descriptions, see the report documentation under Available reports.
-
The default values for metrics, dimensions, time range, and sorting.
-
API limits. For example, the maximum number of dimensions you can use or the maximum number of days from which you can get the data.
-
Available predefined time ranges.
-
-
You can execute the report with the default values, where available, or specify objects to report on in filters. For example, CP codes.
Some filter values authorize your access to data
Dimensions marked as
authorizable: true
in the report options authorize your access to data. When filtering by such dimensions, you can only use objects to which you are authorized. For example, only the CP codes to which you have access in Control Center. If you use any other objects, your API call will result in an error.
Form a request body
To generate a report for custom values instead of the default ones, add a request body to your POST request.
-
Decide which metrics and dimensions you want to include in your report and list their names in the
metrics
anddimensions
arrays, respectively.- To see which metrics and dimensions are available for your report, get the report options.
- For the descriptions of metrics and dimensions, see the report documentation under Available reports.
-
Form the
filters
array of objects to narrow down the report data. See how to use filters. -
Decide how to sort the data. In the
SortBys
array, include the name of the metric or dimension by which you want to sort, and the sorting order,ASCENDING
orDESCENDING
. -
In the
limit
field, you can set how many rows of data the API response should return.
JSON request members
Member | Type | Description |
---|---|---|
dimensions | Array of strings | Array of dimensions to include in the report for grouping results. |
metrics | Array of strings | Array of metrics to include in the report. |
filters | Array of objects | Filters used to narrow down the data. You can filter by metrics and dimensions. See the types of objects you can use in filters. Each report can have its own set of supported filters. For example, it can support filtering by dimensions only. Check the report documentation under Available reports to see which filters you can use. |
sortBys | Array of objects | Metrics or dimensions for sorting the data. You can set the sortyBys for multiple columns. For each object, include the name of the metric or dimension by which you want to sort, and the sortOrder , ASCENDING or DESCENDING . |
limit | Number | Limits the number of rows returned in the API response. |
Request body example
{
"dimensions": [
"url",
"token",
"domain",
"tokenWithVersion"
],
"metrics": [
"hits",
"bytes",
"hits200",
"bytes200",
"pristineBytes",
"averagePristineBytes"
],
"filters": [
{
"dimensionName": "cpcode",
"operator": "IN_LIST",
"expressions": [
"909500"
]
},
{
"dimensionName": "token",
"operator": "BEGINS_WITH",
"expressions": [
"12345"
]
}
],
"sortBys": [
{
"name": "hits200",
"sortOrder": "DESCENDING"
}
],
"limit": 1000
Specify query parameters
In your POST request, you can use these query parameters:
Parameter | Sample | Description |
---|---|---|
start | 2023-06-01T00:00:00Z | Report start date in ISO-8601. Use this parameter together with end , or else replace both with a fixed timeRange . |
end | 2023-06-04T00:00:00Z | Report end date in ISO-8601. Use this parameter together with start , or else replace both with a fixed timeRange . |
timeRange | LAST_1_WEEK | Predefined time range you can use as an alternative to the start and end parameters. One of: LAST_15_MINUTES , LAST_30_MINUTES , LAST_1_HOUR , LAST_3_HOURS , LAST_6_HOURS , LAST_12_HOURS , LAST_1_DAY , LAST_2_DAYS , LAST_1_WEEK , LAST_30_DAYS , or LAST_90_DAYS . Support for specific time range values may vary by report type. See the report documentation under Available reports . |
async | true | Optional flag, true or false . It enables the asynchronous flow of retrieving the data. The default value is false . Read more about retrieving data asynchronously. |
pageSize | 1000 | The size of a page in an async query. By default, the page size is the report's maximum number of returned data points, configured by thedataPointsLimit setting. If a report doesn't have this setting, the default value is 50000 . |
Set the report time range
Set the report time range by including query parameters in your POST request. Use one of these methods:
-
The
start
andend
parameters with the start and end dates in the ISO-8601 format. Example:/reporting-api/v2/reports/{productFamily}/{reportingArea}/{report}/data?start=2023-06-01T00:00:00Z&end=2023-06-04T00:00:00Z
-
The
timeRange
parameter with a predefined time range. Each report can support a different set of predefined time ranges. See the report documentation under Available reports for a list of supported time ranges. Example:/reporting-api/v2/reports/{productFamily}/{reportingArea}/{report}/data?timeRange=LAST_6_HOURS
Use either the
timeRange
parameter or thestart
andend
parameters. Don’t combine the two methods in one API call.
Enable asynchronous mode
Set the async
flag with the true
value as a query parameter in your POST request to enable the asynchronous mode. See how to retrieve data asynchronously. Example:
/reporting-api/v2/reports/{productFamily}/{reportingArea}/{report}/data?async=true
Execute the report
Send your POST request to execute the report. As a response, you get the report data as a JSON object.
Get CSV output
To get CSV data instead of JSON, set the Accept
header to text/csv, application/problem+json
for a CSV output with JSON error messaging.
Integrate with Grafana
You can visualize and observe data from the Reporting API v2 in Grafana. See how to use the Insights Datasource Plugin.
You can get Grafana with the Insights Datasource Plugin already installed through the Cloud Manager's Marketplace.