SharePoint REST APIs restrict results and return a limited amount of data to improve performance. One of the restrictions is the threshold limit to read data from a list which means we cannot read more than 5000 items from a list for an API call. The same rule applies to Search APIs also; it returns only 500 rows at a time.
Since we are searching across the tenant/site, there are more chances for us ending up with more than 500 rows per search.
How to get the total number of rows expected to be returned through the Search API call?
The total number of rows expected to be returned from your search query will be available in the below object mapping of the response.
PrimaryQueryResult.RelevantResults.TotalRows
Since we are searching across the tenant/site, there are more chances for us ending up with more than 500 rows per search.
How to get the total number of rows expected to be returned through the Search API call?
The total number of rows expected to be returned from your search query will be available in the below object mapping of the response.
PrimaryQueryResult.RelevantResults.TotalRows
Get the total number of rows returned in the current search request?
The total number of rows returned in the current search will be available in the below object mapping of the response.
PrimaryQueryResult.RelevantResults.Rowcount
The traditional pagination is the core concept to handle the search results in more than 500 rows. This approach will fit 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,
startrow=501
Let me explain with an example. Below is a sample url to get the contents from the tenant with the Sharepoint text,
https://tenantName.sharepoint.com/search/_api/search/query?querytext='sharepoint’
We can also restrict the number of results to be returned from the Search API result with the parameter rowlimit like below,
https://tenantName.sharepoint.com/search/_api/search/query?querytext='sharepoint&rowlimit=500’
The startrow parameter specifies from which row it has to start the search, for example, if you specify the start row as 501, the search will be performed from 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. Then, make the second call to the same Search API with the same refiners and parameters.
URL
https://tenantName.sharepoint.com/search/_api/search/query?querytext='sharepoint&rowlimit=500&startrow=501’
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;
- this.searchWithPaging(startRow);
- }
- }
How to build SharePoint Framework Applications
The following blog posts will help you in detail about building SPFx applications,
The following blog posts will help you 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 the comments.

Deepak UpadhyaPosted Oct 1, 2018, 1:43 AM
No I am executing the script on html website you can call it as https://abc.com. So i need to Call share point online from that. in simple words, in c sharp corner site. how to display Sharepoint online list [ announcements] items
Deepak UpadhyaPosted Sep 21, 2018, 7:54 AM
<html> <head> <script src="/jquery.min.js"></script> <script> $(document).ready(function() { function executesearch(){ var siteurl = "https://abc.com/sites/space2/xyz/_api/lists/getbytitle('Pages')/Items"; $.ajax({ url: siteurl, method: "GET", headers: { "Accept": "application/json; odata=verbose" }, success: function (data) { if (data.d.results.length > 0 ) { alert(data); } }, error: function (data) { alert("Error: "+ siteurl); } }); } $("#search-button").off().click(function(e) { executesearch(); }); }); </script> </head> <body> <div class="test"> <button class="btnsearch" id="search-button"> FIND CONTENT</button> </div></body> </html>
Deepak UpadhyaPosted Sep 21, 2018, 7:52 AM
How to Display SharePoint Online 365 List Items on non - share point site , you can say a site built using html. how we can connect? I have tried using simple html page and REST API. its giving error as "Access Denied". Looks like I am missing something or i am using wrong methods. Please help