The REST API’s on offer in SharePoint are truly staggering and open the doors to endless possibilities. You can query pretty much anything from a document library or list using the endless API’s. In this article you can find some useful REST URLs for searching for users within a SharePoint site.

This is very useful when you need to do something like granting a specific user permissions on a list or library which only accepts the users ID as the input key.

Using the REST API to pull back user details from SharePoint Online, modify the highlighted fields to match your requirements:

Search by user’s Display Name
https://TENANCY.sharepoint.com/_api/web/siteusers?$filter=substringof(‘USERNAME‘, Title)&$select=ID

Search by Login Name
https://TENANCY.sharepoint.com/_api/web/siteusers?$filter=LoginName eq ‘i%3A0%23.f%7Cmembership%7Cusername%40EmailDomain‘&$select=ID

Search by User ID
https://TENANCY.sharepoint.com/_api/web/siteusers?$filter=ID eq number

Notice: Each site collection will have a different set of users associated to it and in turn each user will most likely have a different ID for each site collection depending on when they where added. If you want a static ID then you will need to use the GUID.