API report contentName AND contentPiece


I had tracking Contents in tags for some elements with
data-track-content data-content-name="events views" data-content-piece="XX"

I have the good statistics in my Matomo (see image)

I want to give datas with the API ?!?

I can extract datas of the contentName “events views” or of the contenPieces BUT I would like to have the data as in Matomo :

contentName “event views” and inside, the numbre for each contentPiece :
For ex., an array : myArray[contentName][contentPieces]


I find the solution :

I must NOT use a simple " Reporting API request" BUT a “Report Metadata API Methods”.

See : https://developer.matomo.org/api-reference/reporting-api-metadata

It’s logic because it’s not simply a request to one table but a request with junction of tables …

Example for datas of all ‘contents’ in 1 year :


Rem : Raw data are in the object ‘reportData’.

Kind regards.