Monday, December 3, 2018

Graph API Performance

Microsoft Graph API is used to get data from Office 365. It is using as gateway to get more amount of data with optimized amount of time. I will share some tips to increase the performance.


Paging

In some case requested API will return more number of data. In that case we can use paging to fetch data. We need use $top give page limit. If we have multiple pages, Graph will return odata.nextlink. Maximum threshold for $top is 999

For Example: https://graph.microsoft.com/v1.0/users?$top=100

Query Parameters

Instead of getting default properties from API response. We will specify properties which we want to retrieve as well as amount to data. We can use following parameters with API URL,
  • $top
  • $select
  • $expand
  • $filter
  • $format
  • skip
For Example:

https://graph.microsoft.com/v1.0/users?$top=100
https://graph.microsoft.com/v1.0/users?$select=displayName
https://graph.microsoft.com/v1.0/users?$filter=displayName eq John

https://graph.microsoft.com/v1.0/users?$format=json
Note: We can get CSV also. But Reports API URL doesn't support JSON format

https://graph.microsoft.com/v1.0/users?$skip=10

Microsoft has been recommended to use Query Parameter and paging as Best Practice. As well as we have to consider about number of calls to API. MS Graph supports throttling limit for concurrent calls and prevent the over usage.