Skip to main content
Join the official Python Developers Survey 2018 and win valuable prizes: Start the survey!

Office 365 REST client for Python

Project description

# About
Office365 REST API client for Python

The list of supported Office 365 REST APIs:

- [SharePoint REST API]( (_supported_ versions: [SharePoint 2013](, SharePoint 2016, SharePoint Online and OneDrive for Business)
- [Outlook REST API](
- [Outlook Contacts REST API](
- [Outlook Calendar REST API](
- [Outlook Mail REST API](

## Status

[![Build Status](](

# Installation

Use pip:

pip install Office365-REST-Python-Client

# Usage: working with SharePoint resources

There are **two approaches** available to perform REST queries:

1) via `ClientRequest class` where you need to construct REST queries by specifying endpoint url, headers if required and payload (aka low level approach)

The first example demonstrates how to read Web resource:

import json

from office365.runtime.auth.authentication_context import AuthenticationContext
from office365.runtime.client_request import ClientRequest
from office365.runtime.utilities.request_options import RequestOptions

ctx_auth = AuthenticationContext(url)
if ctx_auth.acquire_token_for_user(username, password):
request = ClientRequest(ctx_auth)
options = RequestOptions("{0}/_api/web/".format(url))
options.set_header('Accept', 'application/json')
options.set_header('Content-Type', 'application/json')
data = request.execute_query_direct(options)
s = json.loads(data.content)
web_title = s['Title']
print "Web title: " + web_title
print ctx_auth.get_last_error()

2) via `ClientContext class` where you target client object resources such as Web, ListItem and etc.

from office365.runtime.auth.authentication_context import AuthenticationContext
from office365.sharepoint.client_context import ClientContext

ctx_auth = AuthenticationContext(url)
if ctx_auth.acquire_token_for_user(username, password):
ctx = ClientContext(url, ctx_auth)
web = ctx.web
print "Web title: {0}".format(['Title'])

print ctx_auth.get_last_error()

# Python Version
Python 2.7 is fully supported.

# Third Party Libraries and Dependencies
The following libraries will be installed when you install the client library:
* [requests](

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
Office365-REST-Python-Client-2.0.0.tar.gz (23.9 kB) Copy SHA256 hash SHA256 Source None Jul 17, 2017

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page