Share via

What's the best way to paginate large data set's using the Graph Search API?

Mikael Svenson 1 Reputation point
Oct 14, 2021, 7:49 AM

Using the SharePoint Search API there is guidance at https://learn.microsoft.com/en-us/sharepoint/dev/general-development/pagination-for-large-result-sets on how to page large data sets.

What's the advice for similar scenarios using the Graph Search API, and for the different content sources available?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,428 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Danstan Onyango 3,901 Reputation points Microsoft Employee
    Oct 22, 2021, 6:29 AM

    I suggest you look closely at the Graph API pagination guide - Paging Microsoft Graph data in your app and Microsoft Graph throttling guidance

    Graph API endpoints return an @odata.nextLink property when pagination is triggered.

    How to trigger pagination - In both cases you will get @odata.nextLink.

    1. You can trigger Graph API response pagination by specifying the $top operator with a value - This requires that you understand the page size limits of the workload. See this GitHub thread for more.
    2. Or you can run your first request and let Graph decide to paginate.

    To get next page you just need to call @odata.nextLink. A few things to keep in mind:

    1. Pagination is supported differently across graph workloads - See Paging Microsoft Graph data in your app
    2. Check the throttling guide to make sure you don't run into throttling and how to deal with that.
    0 comments No comments

  2. Mikael Svenson 1 Reputation point
    Oct 26, 2021, 2:21 PM

    odata.nextLink is correct for most Graph API's, but not for the search API at https://graph.microsoft.com/v1.0/search/query, so my question remains.

    0 comments No comments

  3. RajeshKumarMSFT 1,976 Reputation points Microsoft External Staff
    Feb 14, 2022, 1:09 PM

    Hello, MikaelSvenson-4538

    Hope you are doing well,

    Regarding pagination using Graph search API please look at the details below.

    For pagination of the Graph API search results by specifying the following two properties in the query request body:

    from - An integer that indicates the 0-based starting point to list search results on the page. The default value is 0.
    size - An integer that indicates the number of results to be returned for a page. The default value is 25.

    174123-pagination.png

    For search Limits with different resources and Best Practices please follow this Refernce Link

    Refer the below links for more details on Graph API search pagination.
    https://learn.microsoft.com/en-us/graph/api/resources/search-api-overview?view=graph-rest-1.0
    https://learn.microsoft.com/en-us/graph/paging

    0 comments No comments

  4. Mikael Svenson 1 Reputation point
    Feb 14, 2022, 5:03 PM

    Hi, using your start offset method, how far can you page? 500 results, 5,000 results, all results? I know how paging works, just curious what the Graph guidance is - similar to the SharePoint search specific guidance if you want to loop over a very large result set.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.