Skip to main content
Skip to main content
Microsoft 365

Client library for Office 365 admin reporting web service now available

Julien Pierre is a program manager and Toney Sui is a software engineer with the Office big data team in Beijing, China.

If your company has deployed Office 365 and it has a central monitoring solution that enables you to continually look at the health of your IT services in one unified place—such as a help desk, reporting dashboard or other solution—there’s good news. Developers and independent software vendors (ISV) with a central monitoring solution like this can now use that solution to monitor Office 365 along with your other IT services, using the OData API. This new client library, the Office 365 Reporting Web Service Client Library, is available in .NET and makes it easier to export reporting data.

The library is available on

Client library for Office 365 1

The client library simplifies access to the API

Office 365 provides a REST-based API that enables developers to access their tenant admin reports’ data, such as OneDrive for Business user activity logs, a range of Exchange- and Lync-related reports, and more. You can code directly against the REST API to fetch data and perform simple queries. However, it requires a specific logic in order to properly fetch a complete data set, especially when you’re dealing with potentially hundreds of thousands of records for certain reports, constructing the right URLs and maintaining data integrity on the target store. By using this client library to access the Office 365 Reporting web service, you can reduce the complexity of code you need to write to access the API. We are providing this library for .NET only.

With this client library, you can:

  • Fetch data from a report.
  • Specify a date range for target querying.
  • Remember the last record you fetched for continuous data exporting.
  • Implement your own record and trace logger processor.

For example, here’s the .NET C# code to fetch the mailbox usage detail report:

using Microsoft.Office365.ReportingWebServiceClient;
using System;
namespace O365ReportingDataExport
    internal class Program
        private static void Main(string[] args)
            ReportingContext context = new ReportingContext();
            context.UserName = @"PUT YOUR OFFICE 365 USER EMAIL ADDRESS HERE";
            context.Password = @"PUT YOUR OFFICE 365 USER PASSWORD HERE";
            //FromDateTime & ToDateTime are optional, default value is DateTime.MinValue if not specified
            context.FromDateTime = DateTime.MinValue;
            context.ToDateTime = DateTime.MinValue;
            context.SetLogger(new MyLogger());
            IReportVisitor visitor = new MyReportVisitor();
            ReportingStream stream1 = new ReportingStream(context, "MailboxUsageDetail", "stream1");
            Console.WriteLine("Press Any Key...");
        private class MyLogger : ITraceLogger
            public void LogError(string message)
            public void LogInformation(string message)
        private class MyReportVisitor : IReportVisitor
            public override void VisitBatchReport()
                foreach (ReportObject report in this.reportObjectList)
            public override void VisitReport(ReportObject record)
                Console.WriteLine("Record: " + record.Date.ToString());

If you do not specify a From/To date time, the first query will try to fetch the earliest top 1000 records and gradually fetch all the data in chunks of 1000.

Client library for Office 365 2

Running the code sample above in Visual Studio 2013.

For each record retrieved from the API, the client library goes through the VisitReport method, which enables you to process the record the way you want, for example, by saving it to a .csv file, third-party Business Intelligence software, or a SQL Server database.

Client library for Office 365 3

Exploring a record’s properties in Visual Studio 2013.

Reports currently supported by the client library

The reports currently supported are:

  • GroupActivity
  • GroupActivityDaily
  • GroupActivityMonthly
  • GroupActivityWeekly
  • GroupActivityYearly
  • MailboxActivity
  • MailboxActivityDaily
  • MailboxActivityMonthly
  • MailboxActivityWeekly
  • MailboxActivityYearly
  • MailboxUsage
  • MailboxUsageDetail
  • StaleMailbox
  • StaleMailboxDetail 

You can find more information on the all the reports available to admins in the Office 365 reporting web service.

Note: Your Office 365 subscription might not include all of the reports listed above. To see which reports are part of your subscription, check the Reports section of Office 365 in your Office 365 admin center.


Have questions? Connect with us on StackOverflow. Tag your question with [O365RwsClient].

Be sure to also connect with the team on the Office 365 Technical Network on Yammer.

Your feedback about this library is important to us.

—Julien Pierre

You may also like these articles

Image for: Logo for the "Rise of the IT leader" infographic, with an arrow pointing upward.

The rise of the IT leader

Gain insights to help you become an IT leader.

Image for: Featured image displays two employees holding documents, engaged in a meeting.

Collaboration hacks from real-life teams

Download the new eBook, “Collaboration hacks from real-life teams,” to learn how companies have reinvented their workplace culture to compete in an information-intensive, interconnected world, where innovation happens in real-time, around the clock and across time zones and geographies.

Image for: Image shows a collage featuring a man checking his email from a mobile device, another contemplating an email and the letters "IT."

3 ways to outsmart shadow IT

Download our new infographic to learn how IT can help the business before business users help themselves.