SpRestLib

SpRestLib

  • Download
  • Get Started
  • API Documentation
  • SharePoint Guides
  • GitHub

›API Reference

Get Started

  • Installation
  • Promise You Will Love It
  • Promise-based Operations

Features

  • Library Integration
  • Library Options
  • SharePoint via Node.js
  • Utility Methods

API Reference

  • List/Library Methods (SP.List)
  • File Methods (SP.File)
  • Folder Methods (SP.Folder)
  • Site Methods (SP.Web)
  • User Methods (SP.User)
  • REST API Methods

SpRestLib UI

  • Form Binding

Help / Support

  • SharePoint Authentication

Site Methods (SP.Web)

Syntax

sprLib.site().info()
sprLib.site(siteUrl).info()

Returns: Array of site properties

Site Properties

Property NameTypeDescription
AssociatedMemberGroupobjectObject with Group properties (Id,Title,OwnerTitle)
AssociatedOwnerGroupobjectObject with Group properties (Id,Title,OwnerTitle)
AssociatedVisitorGroupobjectObject with Group properties (Id,Title,OwnerTitle)
CreatedstringDate (ISO format) the site was created
DescriptionstringSite Description
IdGUIDThe SP GUID of the Site
LanguagenumberSP.Language.lcid property
LastItemModifiedDatestringDate (ISO format) an item was last modified
LastItemUserModifiedDatestringDate (ISO format) an item was last modified by a User
OwnerobjectObject with Group properties (Email,LoginName,Title,IsSiteAdmin)
RequestAccessEmailstringEmail that receives access requests for this site/subsite
SiteLogoUrlstringRelative URL to the site's logo image
TitlestringThe Title of the Site/Subsite
UrlstringAbsolute site URL
WebTemplatestringWeb template name

Sample Code

sprLib.site().info()
.then(function(objSite){ console.table([objSite]) });

/*
.-------------------------------------------------------------------------------------------------------------------------------------.
|        Prop Name         |                                                Prop Value                                                |
|--------------------------|----------------------------------------------------------------------------------------------------------|
| Id                       | "123b4f37-6a13-4bc8-869a-08b5e4b7c058"                                                                   |
| Title                    | "SpRestLib Dev Site"                                                                                     |
| Description              | "Main O365 Dev Site for SpRestLib."                                                                      |
| Language                 | 1033                                                                                                     |
| Created                  | "2016-08-16T14:53:31.327"                                                                                |
| LastItemModifiedDate     | "2017-10-28T23:06:13Z"                                                                                   |
| LastItemUserModifiedDate | "2017-10-28T23:06:13Z"                                                                                   |
| RequestAccessEmail       | "someone@example.com"                                                                                    |
| SiteLogoUrl              | "/sites/dev/SiteAssets/images/sample_company_logo.png"                                                   |
| Url                      | "https://brent.sharepoint.com/sites/dev"                                                                 |
| WebTemplate              | "STS"                                                                                                    |
| AssociatedMemberGroup    | {"Id":8,"Title":"Dev Site Members","OwnerTitle":"Dev Site Owners"}                                       |
| AssociatedOwnerGroup     | {"Id":6,"Title":"Dev Site Owners","OwnerTitle":"Dev Site Owners"}                                        |
| AssociatedVisitorGroup   | {"Id":7,"Title":"Dev Site Visitors","OwnerTitle":"Dev Site Owners"}                                      |
| Owner                    | {"LoginName":"brent@microsoft.com","Title":"Brent Ely","Email":"brent@microsoft.com","IsSiteAdmin":true} |
'-------------------------------------------------------------------------------------------------------------------------------------'
*/

Get Site Lists

Syntax:
sprLib.site().lists()
sprLib.site(siteUrl).lists()

Returns: Array of site lists

List Properties

Property NameTypeDescription
BaseTemplatenumberSP.List.baseTemplate property value - ex: 100
BaseTypestringSP.BaseType property value - ex: "List"
DescriptionstringList Description
HiddenbooleanIs list hidden?
IdGUIDThe SP GUID of the List
ImageUrlstringRelative URL to the list's logo image
ItemCountnumberTotal items in the List/Library
ParentWebUrlstringRelative URL of parent web site
ServerRelativeUrlstringRelative URL of the list itself - ex: "/HR/Lists/Employees"
TitlestringTitle of the List

Sample Code

sprLib.site().lists()
.then(function(arr){ console.table([arr[0]]) });

/*
.------------------------------------------------------------.
|     Prop Name     |               Prop Value               |
|-------------------|----------------------------------------|
| Id                | "8fda2798-daba-497d-9840-df87b08e09c1" |
| Title             | "Employees"                            |
| Description       | "All company personnel"                |
| ItemCount         | 238                                    |
| BaseType          | "List"                                 |
| BaseTemplate      | 100                                    |
| Hidden            | false                                  |
| ImageUrl          | "/_layouts/15/images/itgen.png?rev=44" |
| ParentWebUrl      | "/sites/dev"                           |
| ServerRelativeUrl | "/sites/dev/Lists/Employees"           |
'------------------------------------------------------------'
*/

Get Site Permissions

Syntax:
sprLib.site().perms()
sprLib.site(siteUrl).perms()

Returns: Array of site permissions

Perm Properties

Property NameTypeDescription
Memberobjectobject with Member properties (Title,PrincipalId,PrincipalType)
Rolesobjectarray of Role objects with properties: (Name,Hidden)

Sample Code

sprLib.site().perms()
.then(function(arrayResults){ console.table(arrayResults) });

/*
.-----------------------------------------------------------------------------------------------------------------------------------------------------------.
|                                        Member                                         |                               Roles                               |
|---------------------------------------------------------------------------------------|-------------------------------------------------------------------|
| {"Title":"Excel Services Viewers","PrincipalType":"SharePoint Group","PrincipalId":5} | [{"Hidden":false,"Name":"View Only"}]                             |
| {"Title":"Dev Site Owners","PrincipalType":"SharePoint Group","PrincipalId":6}        | [{"Hidden":false,"Name":"Full Control"}]                          |
| {"Title":"Dev Site Visitors","PrincipalType":"SharePoint Group","PrincipalId":7}      | [{"Hidden":false,"Name":"Read"}]                                  |
| {"Title":"Dev Site Members","PrincipalType":"SharePoint Group","PrincipalId":8}       | [{"Hidden":false,"Name":"Design"},{"Hidden":false,"Name":"Edit"}] |
'-----------------------------------------------------------------------------------------------------------------------------------------------------------'
*/

Get Site Groups

Syntax:
sprLib.site().groups()
sprLib.site().groups(options)
sprLib.site(siteUrl).groups()

Usage: Filter Options allow you to return a single group instead of all the site groups.

Group Filter Options

PropTypeDescriptionPossible Values
idnumbergroup idgroup id to query. Ex: {id:123}
titlestringgroup titlegroup title to query. Ex: {title:'Dev Owners'}

Returns: Array of site Groups

Group Properties

Property NameTypeDescription
AllowMembersEditMembershipbooleanWhether members can edit the group
DescriptionstringGroup Description
IdGUIDGroup ID
OwnerTitlestringOwner Title
PrincipalTypestringGroup, User, etc.
TitlestringTitle of the Group
Usersobjectarray of User objects with properties: (Id,LoginName,Title)

Sample Code

sprLib.site().groups()
.then(function(arrayResults){ console.table(arrayResults) });

/*
.----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------.
| Id |         Title          |  PrincipalType   |             Description            |    OwnerTitle     | AllowMembersEditMembership |                     Users                                         |
|----|------------------------|------------------|------------------------------------|-------------------|----------------------------|-------------------------------------------------------------------|
|  8 | Dev Site Members       | SharePoint Group | contribute permissions: Dev Site   | Dev Site Owners   | true                       | []                                                                |
|  6 | Dev Site Owners        | SharePoint Group | full control permissions: Dev Site | SharePoint Group  | false                      | [{"Id":99,"LoginName":"brent@microsoft.com","Title":"Brent Ely"}] |
|  7 | Dev Site Visitors      | SharePoint Group | read permissions: Dev Site         | SharePoint Group  | false                      | []                                                                |
'----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------'
*/

sprLib.site().groups({ title:'Dev Site Members' })
.then(function(arrayResults){ console.table(arrayResults) });

/*
.----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------.
| Id |         Title          |  PrincipalType   |             Description            |    OwnerTitle     | AllowMembersEditMembership |                     Users                                         |
|----|------------------------|------------------|------------------------------------|-------------------|----------------------------|-------------------------------------------------------------------|
|  8 | Dev Site Members       | SharePoint Group | contribute permissions: Dev Site   | Dev Site Owners   | true                       | []                                                                |
'----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------'
*/

Get Site Roles

Syntax:
sprLib.site().roles()
sprLib.site(siteUrl).roles()

Returns: Array of SiteCollection Roles (result is the same if siteUrl is provided)

Role Properties

Property NameTypeDescription
DescriptionstringRole Description
HiddenbooleanWhether this Role is hidden or not
IdGUIDRole ID
NamestringRole Name
RoleTypeKindnumberSP.RoleDefinition.roleTypeKind value

Sample Code

sprLib.site().roles()
.then(function(arrayResults){ console.table(arrayResults) });

/*
.-------------------------------------------------------------------------------------------------------------------.
|     Id     |      Name      |                         Description                         | RoleTypeKind | Hidden |
|------------|----------------|-------------------------------------------------------------|--------------|--------|
| 1073741829 | Full Control   | Has full control.                                           |            5 | false  |
| 1073741828 | Design         | Can view, add, update, delete, approve, and customize.      |            4 | false  |
| 1073741830 | Edit           | Can add, edit and delete lists and items and documents.     |            6 | false  |
| 1073741827 | Contribute     | Can view, add, update, and delete list items and documents. |            3 | false  |
| 1073741826 | Read           | Can view pages and list items and download documents.       |            2 | false  |
| 1073741825 | Limited Access | Can view specific lists, document libraries, list items...  |            1 | true   |
| 1073741924 | View Only      | Can view pages, list items, and documents.                  |            0 | false  |
'-------------------------------------------------------------------------------------------------------------------'
*/

Get Site Subsites

Syntax:
sprLib.site().subsites()
sprLib.site(siteUrl).subsites()

Returns: Array of subsites under the current or specified location

Subsite Properties

Property NameTypeDescription
CreatedstringDate (ISO format) that this Site was created
IdGUIDSP GUID for this site
LanguagenumberSP.Language.lcid property
ModifiedstringDate (ISO format) that this Site was last modified
NamestringSite Name
SiteLogoUrlstringrelative URL to site logo image
UrlAbsstringabsolute URL of this site
UrlRelbooleanrelative URL of this site

Sample Code

sprLib.site().subsites()
.then(function(arrayResults){ console.table(arrayResults[0]) });

/*
// Subsite Object
.-----------------------------------------------------------------.
|  Prop Name  |                    Prop Value                     |
|-------------|---------------------------------------------------|
| Id          | 822555ab-9376-4a1b-925b-82dcc7bf3cbd              |
| Name        | Sandbox                                           |
| Created     | 2017-09-30T04:27:51                               |
| Modified    | 2017-10-25T03:48:39Z                              |
| Language    | 1033                                              |
| SiteLogoUrl | /sites/dev/SiteAssets/sprestlib-logo.png          |
| UrlAbs      | https://brent.sharepoint.com/sites/dev/sandbox    |
| UrlRel      | /sites/dev/sandbox                                |
'-----------------------------------------------------------------'
*/

Get Site Users

Syntax:
sprLib.site().users()
sprLib.site(siteUrl).users()

Returns: Array of users under the current or specified location

Notes:

  • If siteUrl is omitted, then all users in the entire SiteCollection are returned. Otherwise, only the users under the given site are returned (all users with direct grants and all users within Groups that have site permissions).

User Properties

Property NameTypeDescription
Emailstringuser email address
Groupsarrayarray of user's group objects with properties: (Id,Title)
Idnumberuser Id
IsSiteAdminobjectwhether the user us a site collection admin (SCA)
LoginNamestringuser LoginName
Titlestringuser Title

Sample Code

sprLib.site().users()
.then(function(arrayResults){ console.table(arrayResults) });

/*
.------------------------------------------------------------------------------------------------------------------------.
| Id |        Email        |          LoginName         |   Title   | IsSiteAdmin |                Groups                |
|----|---------------------|----------------------------|-----------|-------------|--------------------------------------|
|  9 | brent@microsoft.com | i:0#.f|brent@microsoft.com | Brent Ely | true        | [{"Id":6,"Title":"Dev Site Owners"}] |
'------------------------------------------------------------------------------------------------------------------------'
*/
← Folder Methods (SP.Folder)User Methods (SP.User) →
  • Syntax
    • Site Properties
    • Sample Code
  • Get Site Lists
    • List Properties
    • Sample Code
  • Get Site Permissions
    • Perm Properties
    • Sample Code
  • Get Site Groups
    • Group Filter Options
    • Group Properties
    • Sample Code
  • Get Site Roles
    • Role Properties
    • Sample Code
  • Get Site Subsites
    • Subsite Properties
    • Sample Code
  • Get Site Users
    • User Properties
    • Sample Code
SpRestLib
Docs
Getting Started with SpRestLibSharePoint API ReferenceSharePoint Development GuidesAbout JavaScript Promises
Community
FacebookTwitterPinterestYouTube Channel
More
GitHub IssuesGitHub ProjectSpRestLib on Stack OverflowSite Icons
Copyright © 2019 Brent Ely