We have a SharePoint 2016 list with 15,000 records and we need to get all the items using REST API. We can use top to read only top 5000 records.

If I need to read data in sets of 5000 items and then push it to a JavaScript array, how to achieve this?

1 Answer 1


You can use data.d.__next property and recursive calls to fetch more than 5000 items from SharePoint list like:

var url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('DocumentList')/items?$select=customerID&$top=5000";
    var response = response || [];  // this variable is used for storing list items
    function GetListItems(){
        return $.ajax({
            url: url,  
            method: "GET",  
            headers: {  
                "Accept": "application/json; odata=verbose"  
            success: function(data){
                response = response.concat(data.d.results);
                if (data.d.__next) {
                    url = data.d.__next;
                $.each(response, function(index, item) {
                    arrayCustomerID[index] = item.customerID;
            error: function(error){

Similar thread: Rest to read more than 5000 items from document library

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.