Microsoft Dev Blogs

Introducing the Microsoft Graph Python SDK

thumbnail

Introducing the Microsoft Graph Python SDK

Microsoft has announced the general availability of the Microsoft Graph Python SDK. This SDK allows developers to access the beta and v1 endpoints of Microsoft Graph using a fluent experience that takes advantage of the best features of the Python language.

With the Microsoft Graph Python SDK, developers can easily authenticate their requests using the authentication provider. This provider handles the fetching, caching, and refreshing of tokens automatically, ensuring that requests are always authenticated.

The SDK also provides a fluent experience for building requests. Unlike other fluent experiences in Python, the SDK does not map every endpoint and method to a unique function. Instead, it displays only the methods that correspond to operations on the specified resource, reducing errors and making it easier to write code that runs.

Another feature of the SDK is the built-in retry handler. This handler understands response status codes such as 429 (Too Many Requests), 503 (Service Unavailable), and 504 (Gateway Timeout), which usually require the application to retry the request after some time. The handler reads the Retry-After header and automatically retries the request after the recommended time.

The Microsoft Graph Python SDK also supports Kiota generation. This means that developers can generate a Python SDK for any API they are using in their project, creating a consistent SDK experience across APIs. All that is needed is an OpenAPI description.

To get started with the Microsoft Graph Python SDK, developers can refer to the documentation page. Additionally, the SDK to access the beta endpoint can be found here. Developers can also sign up for the Microsoft 365 Developer Program to get a free Microsoft 365 developer subscription and start building with Microsoft Graph.