Forum Discussion
StefanFried
Jun 13, 2018Iron Contributor
API and/or PowerShell for managing MS Stream
good morning folks I'm unsure if this question has ever been posted (at least i couldn't find any entry here). I would like to know if there are cmdlets available for retrieving statistical MS S...
Christopher Odegard
Nov 11, 2022Brass Contributor
StefanFried
This may or may not be helpful, but I have located the Graph endpoint that returns this information (view count) for video files stored in SharePoint: Get itemAnalytics - Microsoft Graph v1.0 | Microsoft Learn <https://learn.microsoft.com/en-us/graph/api/itemanalytics-get?view=graph-rest-1.0&tabs=http>
For example, the URL
<mytenant>.sharepoint.com/sites/VideoLibrary/_api/v2.0/$metadata#drives('b!.....')/items/<item ID>/analytics/allTime
...returns a JSON object where the "access" node contains the number of views (actionCount) and the number of unique viewers (actorCount).
{
"@odata.context": "<redacted>",
"@oneDrive.displayNamesOfFileViewers": true,
"aggregationInterval": "None",
"startDateTime": "0001-01-01T00:00:00Z",
"endDateTime": "0001-01-01T00:00:00Z",
"isTrending": false,
"access": {
"actionCount": 50,
"actorCount": 15,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
}
The main trick is getting the item ID, but I have not figured out how to determine that for an arbitrary video.