API's to fetch Files/documents related metadata on SharePoint

Naveed Khan 96 Reputation points

Hi Team,

There is an urgent requirement in my project to fetch below metadata of a file on Sharepoint using API.

1.Number of comments made by the author

2.Time spent by author on the document

3.Number of people who opened the document

4.Total number of open comments etc.



Please help me to achieve the above requirements using API. Any help on this will be appreciated.



Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,485 questions
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,546 questions
SharePoint Server Development
SharePoint Server Development
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Development: The process of researching, productizing, and refining new or existing technologies.
1,567 questions
{count} votes

Accepted answer
  1. Naveed Khan 96 Reputation points

    I want to get Who viewed my files? Show Number of Views and Viewer Names on SharePoint Online files

    Can we achieve this with the help of API's as well?

    Please refer to the blog for more details.


2 additional answers

Sort by: Most helpful
  1. Baker Kong-MSFT 3,791 Reputation points

    Hi @Naveed Khan ,

    There is analytics resource in MS Graph that could return viewer info:


    And you can get all activities including Comment Action via below endpoint:



    Best Regards,
    Baker Kong

    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

  2. Naveed Khan 96 Reputation points

    53493-comment.pngHi Team,

    I have a requirement to fetch the below details.

    Please let me know the API with the help of that we can get the below details.(Refer the attached screenshot)

    @Baker Kong-MSFT : Please help with this.

    1.Number of comments made by the author

    2.Total number of open comments etc.