Display Site Usage & Quota Information in SharePoint

Markus Kolbeck
Markus' Blog
Published in
2 min readJun 30, 2016

This article describes how to display Site Usage & Quota Information in SharePoint using default SharePoint REST Services (SP.UsageInfo object) and a simple JavaScript.

The Result

The result looks like this:

SharePoint Storage & Quota Information

The REST Service Endpoint

You can query the service by navigating to the following URL:
http://<sitecollection>/<site>/_api/site/usage

Required Permissions

Keep in mind, that you will have to assign the following permissions within the SharePoint permission level to all users that should be able to see that information:
Site Permissions — View Web Analytics Data — View reports on Web site usage.

View Web Analytics Data

The Solution

The implementation consist of
1. The JavaScript that actually retrieves the values using REST and displays them on the SharePoint page
2. The Content Editor Web Part (CEWP) that is added to the SharePoint Page.

You could also implement it in your MasterPage, but this approach describes it by adding a CEWP to the page.

The JavaScript

Here’s the souce code:

The script connects to the REST service, retrieves the values for the current amount of storage used by the site and also that percentage of the quota limit, and posts the values within a nicely formatted table using a progress bar element.

Save the JavaScipt either to the SharePoint content, e.g. within the Site Assets Library, or in a central location, e.g. the _layouts folder
(C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\TEMPLATE\LAYOUTS).

In my example I chose the latter aproach.

The CEWP

I like to refer to a text file within the CEWP, rather than adding the pieces of code inside the Web Part.
Either way, you will have to add the following lines of code to the CEWP:

<script src="/_layouts/15/JS/jquery-1.5.1.min.js"></script>
<script src="/_layouts/15/JS/QuotaInfo.js"></script>
<div id="container" ></div>

It includes the path to your jquery library, to the JavaScript retrieving and displaying the storage & quota details and the div-container that represents the placeholder for the output.

Additional Information

msdn article "SP.Site.usage property (sp.js)"

msdn article "SP.UsageInfo object (sp.js)"

--

--