Get WebPart Information using REST

This post will give an example of getting webpart information for a page, using the REST API. The gd-sprest library will be used for this example.

Get WebParts for a Page

SharePoint pages have a “Limited WebPart Manager” property that can be used to get the webpart information for a specified page.

import { SPTypes, Web } from "gd-sprest";

// Get the current web
    // Get the target file
    // Get the webpart manager for this page
    // 0 - User
    // 1 - Shared
    // Get the webparts
    // Set the query to include the webpart properties
        Expand: ["WebPart/Properties"]
    // Execute the request
    .execute(webparts => {
        // Parse through the webparts
        for(let i=0; i<webparts.results.length; i++) {
            let wp = webparts.results[i].WebPart;
            let wpProperties = wp.Properties;

            // Code goes here

Sample Output

2010 Workflow Information

HTTP Request Information

Accept: "application/json;odata=verbose"
Content-Type: "application/json;odata=verbose"
X-HTTP-Method: "POST"
X-RequestDigest: [Request Digest Id]
url: "https://[tenant]'/sites/dev/sitepages/home.aspx')/getLimitedWebPartManager(scope=1)/WebParts?$expand=WebPart/Properties"