1

Is there a Graph or SharePoint API which returns storage size information of a site. I have checked:

SP.Site.usage property (sp.js)

But it is not a recommended version. Also I don’t want to use Powershell for this.

1 Answer 1

1

Using SharePoint REST API:

The Microsoft is not documentation/updating the content related to SP.Site.usage property regularly. However it is still supported in SharePoint Online and you can use it without any issue.

Endpoint URL structure:

https://<siteurl>/_api/site/usage

It will will return the something like:

{
    "d": {
        "Usage": {
            "__metadata": {
                "type": "SP.UsageInfo"
            },
            "Bandwidth": "0",
            "DiscussionStorage": "0",
            "Hits": "0",
            "Storage": "221977142",
            "StoragePercentageUsed": 8.0754813825478775E-06,
            "Visits": "0"
        }
    }
}

Storage is a "Storage Used(in Bytes)" and not the "Total Storage". You can calculate the total amount of storage used based on Storage and StoragePercentageUsed in above result.

Using Microsoft Graph:

You can use getSharePointSiteUsageDetail to get details about SharePoint site usage.

  1. reportRoot: getSharePointSiteUsageDetail

  2. SharePoint site usage reports

Using UI/Browser:

You can also get this report from Site Settings --> Site Collection Administration --> Storage Metrics.

Update from Comments:

As of now, getSharePointSiteUsageDetail gets response only in CSV format. However you can convert it to JSON programatically.

Check below article for more details:

Get All The SharePoint Site Collection Usage Details Using Graph API

8
  • "getSharePointSiteUsageDetail" returns a csv. Is there a way to get json in response? Commented Jun 15, 2020 at 13:03
  • Also "Visits" field is not updated and always remains 0 even after multiple visits to the site Commented Jun 15, 2020 at 13:05
  • Check updated answer to convert csv to JSON. Commented Jun 15, 2020 at 13:10
  • Actually I have seen the that Microsoft API's gets throttled very easily if we use csv as output. I had a bad experience in the past because of this. This is the reason for not taking output in csv Commented Jun 15, 2020 at 13:13
  • Have you tried it? Is it working for you? Commented Jun 16, 2020 at 6:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.