SharePoint always comes with some restriction to boost up the performance. One of the restrictions is that a threshold limit to read data from list is 5000, which means we cannot read more than 5000 items from a list for an API call. Here we are going to see how to read all the items in a SharePoint List with more than 5000 items.
The approach we are talking here will fit any type of technology you use to contact SharePoint through Rest API with some slight changes in the headers. Let me explain this for SPFx now.
We could do this with a pagination concept by crawling the pages/items in a list. But the first requirement to go with this approach is we need to know the total item count in the list.
Below is the REST Api url to get item count in a list using spHttpClient GET method
- {YourSiteCollectionUrl}/_api/web/Lists/GetByTitle('YourListTitle')/ItemCount
Below is the REST Api Url to read the paged items list using spHttpClient GET method
- {YourSiteCollectionUrl}/_api/web/Lists/GetByTitle('{YourListTitle}')/items?%24skiptoken=Paged%3DTRUE%26p_ID%3D{ItemToStartsWith}&%24top={TopCount}&$select=Attachments,AttachmentFiles,*&$expand=AttachmentFiles
Let me explain about this in some depth, the core concept is looping through the items. Still here the SharePoint threshold limit of 5000 items per API call applies so your page size should not exceed 5000 items.
Below is a simple overview of how you will get the 15000 items in a list with just 3 API calls.
First API call
ItemsToStartWith=1, TopCount=5000, Rest API Url will be formatted like below
- {YourSiteCollectionUrl}/_api/web/Lists/GetByTitle('{YourListTitle}')/items?%24skiptoken=Paged%3DTRUE%26p_ID%3D1&%24top=5000&$select=Attachments,AttachmentFiles,*&$expand=AttachmentFiles
Second API call
ItemsToStartWith=5001, TopCount=5000, Rest API Url will be formatted like below
- {YourSiteCollectionUrl}/_api/web/Lists/GetByTitle('{YourListTitle}')/items?%24skiptoken=Paged%3DTRUE%26p_ID%3D5001&%24top=5000&$select=Attachments,AttachmentFiles,*&$expand=AttachmentFiles
Third API call
ItemsToStartWith=10001, TopCount=5000, Rest API Url will be formatted like below
- {YourSiteCollectionUrl}/_api/web/Lists/GetByTitle('{YourListTitle}')/items?%24skiptoken=Paged%3DTRUE%26p_ID%3D10001&%24top=5000&$select=Attachments,AttachmentFiles,*&$expand=AttachmentFiles
That’s it we have read all the 15,000 items in a list with 3 API calls.
Below is the basic code snippet to call SharePoint REST Api call using GET method
- this.context.spHttpClient.get(requestUrl, SPHttpClient.configurations.v1).then((response: SPHttpClientResponse) => {
- if (response.ok) {
- response.json().then((responseJSON) => {
- console.log(responseJSON);
- });
- }
- });

Anil kumarPosted Jul 9, 2021, 5:57 AM
Best Alternate code is: public componentDidMount() { var RestUrl = this.props.siteUrl + "/_api/web/lists/getbytitle('CircuitData')/items?$top=100"; this.getAllCircuitNumbers(RestUrl, 0); } public async getAllCircuitNumbers(RestUrl, count) { count++; await this.props.spClientContext.get(`${RestUrl}`, SPHttpClient.configurations.v1).then((response: SPHttpClientResponse) => { return response.json() }).then(data => { let result = {}; if (data.value.length > 0) { result = { items: data.value, nextLink: data['@odata.nextLink'], }; } }); if (result['nextLink'] != 'undefined') { this.getAllCircuitNumbers(result['nextLink'], count); } } console.log(result); console.log(count); }) }
Sibin LeoPosted Feb 4, 2019, 2:33 AM
How you call 3 api while getlistitems method call.we have one api call to retrieve top 5000 items.after getting response we need to call second api?
Bulti DuttaPosted May 29, 2018, 5:54 AM
I was expecting in one call , beating the barrier , nice explanation but nothing new !
Vinodh NarayananPosted May 25, 2018, 12:14 AM
Any how keep going
Vinodh NarayananPosted May 25, 2018, 12:14 AM
Top = 5000 Then how it retrive more than 5000 items can you please explain