You can narrow down the report data by adding the filters
array to your POST request body.
Supported filters are report-specific
API v2 lets you filter by both dimensions and metrics, but 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.
- Run the GET report options operation for more information on available filters. If a dimension or a metric is labeled as
filterable: true
, you can filter by it. If a dimension or a filter is labeled asmandatory: true
, you have to use it as a filter. The report options also show the filter type,TEXT
orENUM
, and, in case ofENUM
filters, available filter values. Example:
{
"name": "responseClass",
"type": "STRING",
"filterable": true,
"mandatory": false,
"filterType": "ENUM",
"filterEnumValues": [
"0xx",
"1xx",
"2xx",
"3xx",
"4xx",
"5xx",
"6xx"
],
"authorizable": false
}
-
Add each filter as an object to the
filters
array in the POST request body.- To filter by a dimension, include:
Field Type Description dimensionName
String Name of the dimension for which you want to filter. For example, cpcode
.operator
String The filtering logic. One of: MATCH_REGEXP
. Shows values that match the specified regular expression. This option has the same behavior as therlike
function from Spark SQL.NOT_MATCH_REGEXP
. Shows values that don't match the specified regular expression. This option has the same behavior as therlike
function from Spark SQL.BEGINS_WITH
. Shows values that start with the specified string.NOT_BEGINS_WITH
. Shows values that don't start with the specified string.ENDS_WITH
. Shows values that end with the specified string.NOT_ENDS_WITH
. Shows values that don't end with the specified string.CONTAINS
. Shows values that contain the specified string.NOT_CONTAINS
. Shows values that don't contain the specified string.EXACT
. Shows values that exactly match the specified string.IN_LIST
. Shows values that are present on the specified list.NOT_IN_LIST
. Shows values that are not present on the specified list.
ENUM
type, you can only use theIN_LIST
andNOT_IN_LIST
operators.expressions
Array of strings Filter values. If the filter type is ENUM, the report options show available values you can use.
- To filter by a metric, include:
Field Type Description metricName
String Name of the metric for which you want to filter. For example, edgeHitsSum
.operator
String The filtering logic. One of: EQUAL
. Shows values that are equal to the specified value.NOT_EQUAL
. Shows values that aren't equal to the specified value.LESS_THAN
. Shows values that are less than the specified value.GREATER_THAN
. Shows values that are greater than the specified value.
expression
String or number Filter value. To filter by a metric, you need to include it in the
metrics
array in the request body.- Example:
"filters": [ { "dimensionName": "cpcode", "operator": "IN_LIST", "expressions": [ "1849", "2084", "2577", "3004" ] }, { "metricName": "edgeHitsSum", "operator": "GREATER_THAN", "expression": "1" } ]
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.