Hi @Volodymyr Yefymenko ,
Hope you are doing well.
We are following below Microsoft article for the same.
itemactivitystat-getactivitybyinterval
GET /drives/{drive-id}/items/{item-id}?getActivitiesByInterval(startDateTime='2017-01-01',endDateTime='2017-01-10',interval='day')
GET /sites/{site-id}/getActivitiesByInterval(startDateTime='2016-01-01',endDateTime='2017-05-20',interval='month')
GET /sites/{site-id}/lists/{list-id}/items/{item-id}/getActivitiesByInterval(startDateTime='2017-05-01',endDateTime='2017-05-20',interval='week')
Please note below important point while using above Graph API.
1] This API only supports a time range of 90 days for daily counts. The value of the startDateTime and endDateTime parameters must represent a time range of less than 90 days.
2] Also time format should be 'YYYY-MM-DD HH:MM:SS'.
I have used below graph API points in Graph Explorer.
GET /drives/{drive-id}?getActivitiesByInterval(startDateTime='2017-01-01',endDateTime='2017-01-10',interval='day')
Response
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives/$entity",
"createdDateTime": "2021-12-11T19:40:08Z",
"description": "",
"id": "b!skFdKh71ok-uWL7vaXnlQucCBBO7HAtJmjdis80LDFOBOUQPwjNnRLwDfs6zXFZf",
"lastModifiedDateTime": "2022-01-26T16:36:29Z",
"name": "OneDrive",
"webUrl": "https://raiinfy-my.sharepoint.com/personal/atul_raiinfy_onmicrosoft_com/Documents",
"driveType": "business",
"createdBy": {
"user": {
"displayName": "System Account"
}
},
"lastModifiedBy": {
"user": {
"email": "Atul@raiinfy.onmicrosoft.com",
"id": "6ab5cc33-a9d6-40b1-a84f-993e06d170f3",
"displayName": "Atul"
}
},
"owner": {
"user": {
"email": "Atul@raiinfy.onmicrosoft.com",
"id": "6ab5cc33-a9d6-40b1-a84f-993e06d170f3",
"displayName": "Atul"
}
},
"quota": {
"deleted": 300,
"remaining": 1099508885650,
"state": "normal",
"total": 1099511627776,
"used": 2741826
}
}
GET /drives/{drive-id}/items/{item-id}?getActivitiesByInterval(startDateTime='2017-01-01',endDateTime='2017-01-10',interval='day')
This will generate c# code like this.
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var getActivitiesByInterval = await graphClient.Drives["{drive-id}"].Items["{driveItem-id}"]
.GetActivitiesByInterval("2012-01-01","2022-02-15","day")
.Request()
.GetAsync();
Response
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives('b%21skFdKh71ok-uWL7vaXnlQucCBBO7HAtJmjdis80LDFOBOUQPwjNnRLwDfs6zXFZf')/list/items/$entity",
"@odata.etag": "\"5b426ff3-f311-4567-935e-f743683e4635,3\"",
"createdDateTime": "2022-01-25T12:18:08Z",
"eTag": "\"5b426ff3-f311-4567-935e-f743683e4635,3\"",
"id": "17",
"lastModifiedDateTime": "2022-02-14T21:05:47Z",
"webUrl": "https://raiinfy-my.sharepoint.com/personal/atul_raiinfy_onmicrosoft_com/Documents/FileP%202.txt",
"createdBy": {
"user": {
"displayName": "SharePoint App"
}
},
"lastModifiedBy": {
"user": {
"email": "Atul@raiinfy.onmicrosoft.com",
"id": "6ab5cc33-a9d6-40b1-a84f-993e06d170f3",
"displayName": "Atul"
}
},
"parentReference": {
"id": "72c8edff-2e19-4483-9168-5d1e44180030",
"siteId": "raiinfy-my.sharepoint.com,2a5d41b2-f51e-4fa2-ae58-beef6979e542,130402e7-1cbb-490b-9a37-62b3cd0b0c53"
},
"contentType": {
"id": "0x0101006F6F7B9301535D428B441925DE15893D",
"name": "Document"
},
"fields@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives('b%21skFdKh71ok-uWL7vaXnlQucCBBO7HAtJmjdis80LDFOBOUQPwjNnRLwDfs6zXFZf')/list/items('17')/fields/$entity",
"fields": {
"@odata.etag": "\"5b426ff3-f311-4567-935e-f743683e4635,3\"",
"FileLeafRef": "FileP 2.txt",
"id": "17",
"ContentType": "Document",
"Created": "2022-01-25T12:18:08Z",
"AuthorLookupId": "1073741822",
"Modified": "2022-02-14T21:05:47Z",
"EditorLookupId": "3",
"_CheckinComment": "",
"LinkFilenameNoMenu": "FileP 2.txt",
"LinkFilename": "FileP 2.txt",
"DocIcon": "txt",
"FileSizeDisplay": "9",
"ItemChildCount": "0",
"FolderChildCount": "0",
"_ComplianceFlags": "",
"_ComplianceTag": "",
"_ComplianceTagWrittenTime": "",
"_ComplianceTagUserId": "",
"_CommentCount": "",
"_LikeCount": "",
"_DisplayName": "",
"AppAuthorLookupId": "9",
"Edit": "0",
"_UIVersionString": "2.0",
"ParentVersionStringLookupId": "17",
"ParentLeafNameLookupId": "17"
}
}
GET /drives/{drive-id}/items/{item-id}?getActivitiesByInterval(startDateTime='2017-01-01 00:00:00',endDateTime='2017-01-01 00:00:00',interval='hour')
GET https://graph.microsoft.com/v1.0/drives/b!skFdKh71ok-uWL7vaXnlQucCBBO7HAtJmjdis80LDFOBOUQPwjNnRLwDfs6zXFZf/list/items/17?getActivitiesByInterval(startDateTime='2022-02-14 20:00:00',endDateTime='2022-02-14 22:00:00',interval='hour')
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives('b%21skFdKh71ok-uWL7vaXnlQucCBBO7HAtJmjdis80LDFOBOUQPwjNnRLwDfs6zXFZf')/list/items/$entity",
"@odata.etag": "\"5b426ff3-f311-4567-935e-f743683e4635,3\"",
"createdDateTime": "2022-01-25T12:18:08Z",
"eTag": "\"5b426ff3-f311-4567-935e-f743683e4635,3\"",
"id": "17",
"lastModifiedDateTime": "2022-02-14T21:05:47Z",
"webUrl": "https://raiinfy-my.sharepoint.com/personal/atul_raiinfy_onmicrosoft_com/Documents/FileP%202.txt",
"createdBy": {
"user": {
"displayName": "SharePoint App"
}
},
"lastModifiedBy": {
"user": {
"email": "Atul@raiinfy.onmicrosoft.com",
"id": "6ab5cc33-a9d6-40b1-a84f-993e06d170f3",
"displayName": "Atul"
}
},
"parentReference": {
"id": "72c8edff-2e19-4483-9168-5d1e44180030",
"siteId": "raiinfy-my.sharepoint.com,2a5d41b2-f51e-4fa2-ae58-beef6979e542,130402e7-1cbb-490b-9a37-62b3cd0b0c53"
},
"contentType": {
"id": "0x0101006F6F7B9301535D428B441925DE15893D",
"name": "Document"
},
"fields@odata.context": "https://graph.microsoft.com/v1.0/$metadata#drives('b%21skFdKh71ok-uWL7vaXnlQucCBBO7HAtJmjdis80LDFOBOUQPwjNnRLwDfs6zXFZf')/list/items('17')/fields/$entity",
"fields": {
"@odata.etag": "\"5b426ff3-f311-4567-935e-f743683e4635,3\"",
"FileLeafRef": "FileP 2.txt",
"id": "17",
"ContentType": "Document",
"Created": "2022-01-25T12:18:08Z",
"AuthorLookupId": "1073741822",
"Modified": "2022-02-14T21:05:47Z",
"EditorLookupId": "3",
"_CheckinComment": "",
"LinkFilenameNoMenu": "FileP 2.txt",
"LinkFilename": "FileP 2.txt",
"DocIcon": "txt",
"FileSizeDisplay": "9",
"ItemChildCount": "0",
"FolderChildCount": "0",
"_ComplianceFlags": "",
"_ComplianceTag": "",
"_ComplianceTagWrittenTime": "",
"_ComplianceTagUserId": "",
"_CommentCount": "",
"_LikeCount": "",
"_DisplayName": "",
"AppAuthorLookupId": "9",
"Edit": "0",
"_UIVersionString": "2.0",
"ParentVersionStringLookupId": "17",
"ParentLeafNameLookupId": "17"
}
}
GET /sites/{site-id}/getActivitiesByInterval(startDateTime='2016-01-01',endDateTime='2017-05-20',interval='month')
GET /sites/{site-id}/lists/{list-id}/items/{item-id}/getActivitiesByInterval(startDateTime='2017-05-01',endDateTime='2017-05-20',interval='week')
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#Collection(itemActivityStat)",
"value": [
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-01-01T00:00:00Z",
"endDateTime": "2022-01-01T23:59:59Z",
"access": {
"actionCount": 0,
"actorCount": 0,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
},
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-01-02T00:00:00Z",
"endDateTime": "2022-01-02T23:59:59Z",
"access": {
"actionCount": 0,
"actorCount": 0,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
},
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-01-03T00:00:00Z",
"endDateTime": "2022-01-03T23:59:59Z",
"access": {
"actionCount": 0,
"actorCount": 0,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
},
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-01-04T00:00:00Z",
"endDateTime": "2022-01-04T23:59:59Z",
"access": {
"actionCount": 2,
"actorCount": 1,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
},
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-01-05T00:00:00Z",
"endDateTime": "2022-01-05T23:59:59Z",
"access": {
"actionCount": 1,
"actorCount": 1,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
},
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-01-06T00:00:00Z",
"endDateTime": "2022-01-06T23:59:59Z",
"access": {
"actionCount": 2,
"actorCount": 1,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
},
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-01-07T00:00:00Z",
"endDateTime": "2022-01-07T23:59:59Z",
"access": {
"actionCount": 0,
"actorCount": 0,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
},
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-01-08T00:00:00Z",
"endDateTime": "2022-01-08T23:59:59Z",
"access": {
"actionCount": 0,
"actorCount": 0,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
},
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-01-09T00:00:00Z",
"endDateTime": "2022-01-09T23:59:59Z",
"access": {
"actionCount": 0,
"actorCount": 0,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
},
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-01-10T00:00:00Z",
"endDateTime": "2022-01-10T23:59:59Z",
"access": {
"actionCount": 0,
"actorCount": 0,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
},
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-01-11T00:00:00Z",
"endDateTime": "2022-01-11T23:59:59Z",
"access": {
"actionCount": 0,
"actorCount": 0,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
},
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-01-12T00:00:00Z",
"endDateTime": "2022-01-12T23:59:59Z",
"access": {
"actionCount": 1,
"actorCount": 1,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
},
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-01-13T00:00:00Z",
"endDateTime": "2022-01-13T23:59:59Z",
"access": {
"actionCount": 0,
"actorCount": 0,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
},
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-01-14T00:00:00Z",
"endDateTime": "2022-01-14T23:59:59Z",
"access": {
"actionCount": 0,
"actorCount": 0,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
},
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-01-15T00:00:00Z",
"endDateTime": "2022-01-15T23:59:59Z",
"access": {
"actionCount": 0,
"actorCount": 0,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
},
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-01-16T00:00:00Z",
"endDateTime": "2022-01-16T23:59:59Z",
"access": {
"actionCount": 0,
"actorCount": 0,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
},
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-01-17T00:00:00Z",
"endDateTime": "2022-01-17T23:59:59Z",
"access": {
"actionCount": 1,
"actorCount": 1,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
},
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-01-18T00:00:00Z",
"endDateTime": "2022-01-18T23:59:59Z",
"access": {
"actionCount": 0,
"actorCount": 0,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
},
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-01-19T00:00:00Z",
"endDateTime": "2022-01-19T23:59:59Z",
"access": {
"actionCount": 0,
"actorCount": 0,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
},
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-01-20T00:00:00Z",
"endDateTime": "2022-01-20T23:59:59Z",
"access": {
"actionCount": 0,
"actorCount": 0,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
},
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-01-21T00:00:00Z",
"endDateTime": "2022-01-21T23:59:59Z",
"access": {
"actionCount": 3,
"actorCount": 2,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
},
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-01-22T00:00:00Z",
"endDateTime": "2022-01-22T23:59:59Z",
"access": {
"actionCount": 0,
"actorCount": 0,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
},
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-01-23T00:00:00Z",
"endDateTime": "2022-01-23T23:59:59Z",
"access": {
"actionCount": 0,
"actorCount": 0,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
},
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-01-24T00:00:00Z",
"endDateTime": "2022-01-24T23:59:59Z",
"access": {
"actionCount": 0,
"actorCount": 0,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
},
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-01-25T00:00:00Z",
"endDateTime": "2022-01-25T23:59:59Z",
"access": {
"actionCount": 3,
"actorCount": 1,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
},
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-01-26T00:00:00Z",
"endDateTime": "2022-01-26T23:59:59Z",
"access": {
"actionCount": 0,
"actorCount": 0,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
},
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-01-27T00:00:00Z",
"endDateTime": "2022-01-27T23:59:59Z",
"access": {
"actionCount": 0,
"actorCount": 0,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
},
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-01-28T00:00:00Z",
"endDateTime": "2022-01-28T23:59:59Z",
"access": {
"actionCount": 0,
"actorCount": 0,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
},
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-01-29T00:00:00Z",
"endDateTime": "2022-01-29T23:59:59Z",
"access": {
"actionCount": 0,
"actorCount": 0,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
},
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-01-30T00:00:00Z",
"endDateTime": "2022-01-30T23:59:59Z",
"access": {
"actionCount": 0,
"actorCount": 0,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
},
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-01-31T00:00:00Z",
"endDateTime": "2022-01-31T23:59:59Z",
"access": {
"actionCount": 0,
"actorCount": 0,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
},
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-02-01T00:00:00Z",
"endDateTime": "2022-02-01T23:59:59Z",
"access": {
"actionCount": 0,
"actorCount": 0,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
},
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-02-02T00:00:00Z",
"endDateTime": "2022-02-02T23:59:59Z",
"access": {
"actionCount": 3,
"actorCount": 1,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
},
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-02-03T00:00:00Z",
"endDateTime": "2022-02-03T23:59:59Z",
"access": {
"actionCount": 1,
"actorCount": 1,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
},
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-02-04T00:00:00Z",
"endDateTime": "2022-02-04T23:59:59Z",
"access": {
"actionCount": 0,
"actorCount": 0,
"timeSpentInSeconds": 0
},
"incompleteData": {
"wasThrottled": false,
"resultsPending": false,
"notSupported": false
}
},
{
"@odata.type": "#microsoft.graph.itemActivityStat",
"aggregationInterval": "None",
"startDateTime": "2022-02-05T00:00:00Z",
"endDateTime": "2022-02-05T23:59:59Z",
"access": {
"actionCount": 0,
"actorCount": 0,
"timeSpentInSeconds": 0
},
"incompleteData": {