Jump to content

Microsoft Graph Python SDK - Public Preview


Recommended Posts

Guest Lee Stott
Posted

Microsoft Graph Python SDK, now available for public preview. Get ready to adopt and utilize the Microsoft Python core library.

 

 

You can now access the beta and v1 endpoints of Microsoft Graph, with a fluent experience, designed to facilitate discoverability and enhance with best features of the Python language.

 

 

 

largevv2px999.png.3995a5817083d5e38f2608667128fdd1.png

 

 

 

Get started with Microsoft Graph Python SDK

 

  • Start with the Microsoft Graph SDKs documentation page.
  • The README and code examples will teach you how to use the Python SDK. And the Upgrade guide contains instructions to upgrade from the Python Core library. You can also find the SDK to access the beta endpoint here.
  • Open an issue for errors you encounter that we didn’t include in our guide or simply to share feedback with us.
  • Sign up for the Microsoft 365 Developer Program to get a free Microsoft 365 developer subscription and start building with Microsoft Graph.

The Microsoft Graph Python SDK

 

 

The Python SDK improves the best of the Python core library, supplying an authentication provider that automatically refreshes access tokens, along with a built-in retry handler that understands response status codes and automatically waits the recommended time. The SDK also provides async experience, allowing the application to work on multiple requests at the same time and perform other operations while it waits for the response, improving the speed and efficiency of the application. It is also equipped with HTTP2 support and model classes corresponding to Microsoft Graph resources, allowing the developer to work with Python objects, automatically serializing and deserializing JSON format in requests and responses.

 

 

 

Fluent Experience in Python SDK

 

 

Contrary to other fluent experiences in Python, we don’t map every endpoint and method to a unique function. Instead, we present a framework to construct any request using method chaining, providing a clean flow that works seamlessly with Python. The fluent pattern contributes to reducing errors by displaying only the methods corresponding to operations on that resource, aided by the IDE’s autocomplete, allowing the developer to confidently type code that runs. The SDK also makes use of type annotations to provide clarity and control during the development process.

 

 

Standardize API Client Output with Kiota

 

 

Continuing our efforts to standardize our tools, this SDK is also generated with Kiota, an open-source project for generating an API client to call any OpenAPI described API, assuring quality and consistency across our tools.

 

 

Authentication provider

 

 

The authentication provider handles the fetching, caching, and refreshing of tokens automatically, ensuring your requests are always authenticated. The auth provider verifies the token is always valid by tracking the expiration and automatically refreshing it in the background before it expires.

 

 

[<script src="https://gist.github.com/isvargasmsft/785e58a5ee92511e051fa48cfe99cfeb.js"></script>]

 

 

Fluent request builder pattern for Python

 

 

The fluent pattern makes the request building experience more intuitive. Instead of passing raw URLs, this new version provides a fluent experience that enhances discoverability and efficiency, also reducing the time spent in reference docs.

 

 

[<script src="https://gist.github.com/isvargasmsft/b682216a1d01e1ad49f21463ba5c0c97.js"></script>]

 

 

This request builder pattern was carefully designed with Python developers in mind, providing enhanced discoverability without mutating the objects.

 

 

Built-in retry handler

 

 

A configurable built-in retry handler understands 429, 503 and 504 response status codes, reading the information in the `Retry-After` header and making decisions accordingly. For throttling status codes, the handler reads the recommendation in the `Retry-After` header and retries after the recommended time.

 

Continue reading...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...