Handling the SharePoint REST API search threshold limit in SPFx

­SharePoint REST API’s restrict the results and it returns limited amount of data so it will improve the performance. One of the restriction is threshold limit to read data from list which means we cannot read more than 5000 items from a list for an API call. The same rule applies for Search API’s also, it will return only 500 rows at a time.

Since we are searching across the tenant/site there is more chance you will end up with more than 500 rows per search.

Get the total number of rows expected to return through the search API call?

Total number of rows expected to be returned from your search query will be available in the below object mapping of the response.


Get the total number of rows returned in the current search request?

Total number of rows returned in the current search will be available in the below object mapping of the response.


The traditional pagination is the core concept to handle the search results more than 500 rows. This approach will fit for any type of technologies you use to contact SharePoint Search through Rest API with some slight changes in the headers. Let me explain this for SPFx now.

Check out our article about Reading more than 5000 items using rest API in SharePoint Framework applications.  Now, handling the threshold limit in search API is not so complicated like handling threshold limit for list items, just add the below parameter in the ODATA query,


Let me explain with an example, below is a sample url to get the contents from the tenant with the text sharepoint,’sharepoint

We can also restrict the number of results to be returned from the Search API result with the parameter rowlimit like below,’sharepoint&rowlimit=500

The start row parameter specifies from which row it has to start the search, for example if you specify the start row as 501, search will be performed from the row 501 and it will return the results from row 501 to row 1000.

Get the total rows expected to return from the search and put in the below logic and make the second call to same search api with same refiners and parameters,


Code Snippet:

let totalRows: number = searchResult.PrimaryQueryResult.RelevantResults.TotalRows;

let pageSize = 500; //maximum rows that search api can return

if (totalRows > pageSize) {

     let totalPages = parseInt((totalRows / pageSize).toString());

        for (let page = 1; page <= totalPages; page++) {

                    let startRow = page * pageSize;




SharePoint Intranet Software

How to build SharePoint Framework Applications?

The following blog posts will help you for sure in detail about building SPFx applications,

                   Build SPFx webparts with Angular 4

                   Deep Dive into SPFx webparts configuration

                   Build SPFx extensions

                   Integrating SPFx apps with visual Studio


If you have any questions/issues about this article, please let me know in comments.

Sharing is Caring!

Leave a Reply

Your email address will not be published. Required fields are marked *