Using API for number of pageviews by multiple custom dimensions

I am struggling with retrieving data with the API for number of pageviews and custom dimensions.

I have 2 custom action dimensions associated with some of my page views. Lets call them dimension1 and dimension2 .

I need to retrieve the number of pageviews by dimension1 and dimension2.

With google analytics I can retrieve the dimension values for each action (=pageview), and filter the results by the dimension values. With analytics this is done with something like
$options = array(
‘dimensions’ => ‘ga:date,ga:dimension1,ga:dimension2’,
‘filters’ => ‘ga:dimension1==PRODUCT_ID’,
‘ga:PROFILEID’ , $fromDate, $toDate, ‘ga:pageviews’, $options)

How would I do this with the matomo API? As far as I could see, there is no way to retrieve pageview count with the values with the dimensions, nor can I filter the results by the dimension values.

The closest I came up with is the API method CustomDimensions.getCustomDimension and using pivotBy


But this produces wrong results. Without the pivotBy I do get correct results, but only for one dimension. How would I split the pagecount for this one dimension to the values of the other dimension?

Any suggestions?