SharePoint Rest API: A Guide to Various Rest API Endpoints

Introduction

In this article, we'll walk through SharePoint REST API and how it can help us in our business. With Rest API, we can use different endpoints to get things done faster and be more productive. It's a powerful tool that can make our work easier and more efficient. Let's see how we can make the most out of it!

What is SharePoint Rest API?

As we all know that REST API (Representational State Transfer Application Programming Interface) is a way for different software applications to talk to each other over the Internet. It allows us to exchange data across various software to perform our tasks seamlessly.

SharePoint Rest API works in a similar pattern. It helps us to remotely work with SharePoint Sites and its data into our Application which supports standard REST capabilities.

How SharePoint Rest API works behind the scenes?

Let’s understand this with the help of little Imagination.

Imagine SharePoint as a big digital warehouse where we can store and manage our files, documents, and other data. The REST API is like the magical door that allows us to interact with this warehouse and lets us perform various actions.

Now how is it gonna allow us to perform actions?

  • Users can interact with SharePoint by sending HTTP requests to perform various actions.
  • Data is exchanged in a simple JSON format, facilitating understanding between users and SharePoint.
  • Prior authentication ensures secure access to the warehouse in terms of adding, updating, or deleting something from the SharePoint warehouse.
  • SharePoint responds to requests with status codes indicating success or errors.

Also, SharePoint Rest API works on Open Data Protocol (OData) which allows to perform tasks such as building APIs for web and mobile applications, integrating data from different sources, and enabling data sharing between organizations.

Ultimately, the REST API simplifies data management, enabling users to efficiently navigate and manipulate their files within SharePoint's system.

SharePoint REST Endpoint Examples

To embark on your journey with the SharePoint REST API, the first step is to generate a REST endpoint. Every REST endpoint URL commences with.

https:///{site_url}/_api/

Further, this endpoint is classified into two groups.

To access a specific site collection, we use the following construction.

https://{site_url}/_api/site

This endpoint represents the root site of a SharePoint site collection. When we make a request to this endpoint, we are accessing information and operations related to the entire site collection.

To access a specific site, use the following construction.

https://{site_url}/_api/web

This endpoint represents the current web (or site) within the SharePoint site collection. When we make a request to this endpoint, we are accessing information and operations specific to the individual site (web) that the URL points to.

Here are various SharePoint REST API endpoint examples.

Operations Rest API EndPoint
Get SharePoint Site Collection https://{site url}/_api/site
Get a particular SharePoint Site or Web https://{site url}/_api/web
Get the SharePoint site title https://{site url}/_api/web/title
Get all lists from a SharePoint site https://{site url}/_api/web/lists
Get all items from a SharePoint list https://{site url}/_api/web/lists/getbytitle(‘list name’)/items
Get a particular column from the SharePoint list https://{site url}/_api/web/lists/getbytitle(‘list name’)?select={columnName}
Get the lookup field column value from the SharePoint list https://{siteurl}/_api/web/lists/getbytitle('Employees')/items?$select=Department/Name,Department/Branch &$expand=Department
Get all columns from a SharePoint list https://{site url}/_api/web/lists/getbytitle(‘list name’)/Fields
Get a SharePoint list by using a list GUIDs https://{site url}/_api/web/Lists(guid 'GUID')
Get SharePoint list item by item id https://{site url}/_api/web/lists/getbytitle(‘list name’)/items(2)
Get SharePoint logged-in user information https://{site url}/_api/web/currentUser
Get all SharePoint site users https://{site url}/_api/web/siteusers
Get all SharePoint groups from the site https://{site url}/_api/web/sitegroups
Get a particular SharePoint group by group id https://{site url}/_api/web/sitegroups/GetById(GroupId)
Get all users from a SharePoint group https://{site url}/_api/web/sitegroups(Id)/users
Get all files from a folder https://{siteurl}/_api/web/GetFileByServerRelativeUrl('/sites/Site Name/Library Name')/Files
Get metadata for the particular document https://{siteurl}/_api/web/GetFileByServerRelativeUrl('/sites/Site Name/Library Name/filename.docx')/listItemAllFields
Get the current version of a file https://{siteurl}/_api/web/lists(List ID)/items(23)?$select=FileLeafRef,OData__UIVersionString
Get the E tag of a document https://{siteurl}/_api/web/GetFileByServerRelativeUrl('/sites/Site Name/Library Name/filename.docx')/etag


Conclusion

So this was brief about what SharePoint Rest API is, how it works and what are the different endpoints we can use in order to get our things done. Hope this Article has provided you insight about the SharePoint Rest API. You can Join me on LinkedIn to follow my learning journey and stay updated with my latest insights and discoveries.