In this blog, I would like to share the code to get the SharePoint list items using SharePoint Rest API. We have already seen how to retrieve the item from SharePoint List using JSOM object model
Here is the detailed documentation for the list and the features.
Steps to retrieve the SharePoint List items using rest API
Follow the below-listed steps to retrieve the items
Step 1
Create one JS file or you can use the content editor web part.
Step 2
Below is the API to get the list items, you can browse this URL in the browser to check whether the API is working or not:
https://sharepoint.com/_api/web/lists/GetByTitle('samplelist')/items
Note
Replace your list name in “samplelist.”
Step 3
Refer to the jQuery in your HTML file or content editor web part.
Use the below code to retrieve the item from SharePoint lists:
- 'use strict';
- ExecuteOrDelayUntilScriptLoaded(initializePage, "sp.js");
- function initializePage() {
- var siteURL;
- var itemsArray = [];
- // This code runs when the DOM is ready and creates a context object which is needed to use the SharePoint object model
- $(document).ready(function() {
- var scriptbase = _spPageContextInfo.webServerRelativeUrl + "/_layouts/15/";
- GetSampleListItems();
- });
- //Retrieve list items from sharepoint using API
- function GetSampleListItems() {
- siteURL = _spPageContextInfo.siteAbsoluteUrl;
- console.log("from top nav - " + siteURL);
- var apiPath = siteURL + "/_api/lists/getbytitle(''samplelist'')/items";
- $.ajax({
- url: apiPath,
- headers: {
- Accept: "application/json;odata=verbose"
- },
- async: false,
- success: function(data) {
- var items; // Data will have user object
- var results;
- if (data != null) {
- items = data.d;
- if (items != null) {
- results = items.results
- for (var i = 0; i < results.length; i++) {
- itemsArray.push({
- "Title": results[i].Title
- });
- }
- }
- }
- },
- eror: function(data) {
- console.log("An error occurred. Please try again.");
- }
- });
- }
- }
Rest API performance is fast compared to JSOM object model.
Using API, we can retrieve the particular column values and we can do the filtering, ordering, and sorting.
Refer to the below image for more options:

Summary
In this blog, we have explored how to retrieve the list items from SharePoint using REST API.

A APosted May 5, 2023, 12:10 AM
Thank you for your posting. Does it work if list contains more than 25k items? I am trying to get filtered data from SharePoint online list which has more than 25k items and number might increase. Please advise.
Bob SmithPosted Jan 15, 2020, 10:09 PM
This is very helpful! I'm hoping you might be able to help me a little further. I am trying to pull information for one column but several rows of a list into a table on a different SharePoint page. The table format has the date from the list places sporadically, not in a nice neat column. Using the code provided above (thank you for that!!) how would I can each item specifically in a table cell?
Ravi KumarPosted Jul 6, 2018, 3:11 AM
Nice work, Kaviya! is there a way to filter a look up column?
krishna murthyPosted Mar 8, 2018, 10:26 PM
How many items can fetch using REST api at a time. could you please provide what is limitation of REST api.
Piyush AgarwalPosted Mar 8, 2018, 4:29 AM
Nice article.... There are endless things that can be achieved using REST api in sharepoint ....