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
Status
Installation
Use pip:
pip install Office365-REST-Python-Client
Usage: working with SharePoint resources
There are two approaches available to perform REST queries:
- via
ClientRequest classwhere 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_request_direct(options)
s = json.loads(data.content)
web_title = s['Title']
print "Web title: " + web_title
else:
print ctx_auth.get_last_error()
- via
ClientContext classwhere 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
ctx.load(web)
ctx.execute_query()
print "Web title: {0}".format(web.properties['Title'])
else:
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:
Metadata
Release files for office365-rest-python-client 2.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| Office365-REST-Python-Client-2.1.3.tar.gz | 34.5 kB | Without provenance | Details for Office365-REST-Python-Client-2.1.3.tar.gz |
Release files / Office365-REST-Python-Client-2.1.3.tar.gz
| Download URL | Office365-REST-Python-Client-2.1.3.tar.gz |
|---|---|
| Size | 34.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
136c1c2bb0ea71bb189489bfb380375fa2edb7dd829c6c8fef0d7c4a6d45847c
|
|
BLAKE2b-256 checksum How to use checksums |
04fa47595c067b6d95ffa52b0c81207267219d5033e58f77d03ccb7a546fa81a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.6.3
|
Security for office365-rest-python-client 2.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.