Skip to main content
2 of 6
edited title
dvdsmpsn
  • 231
  • 1
  • 3
  • 13

Retrieve all sites and all subsites from the SharePoint REST API

Using SharePoint Online, I'm trying to retrieve a list of all sites and subsites.

This API gives me all top level sites, but no subsites:

https://{mycompany}.sharepoint.com/_api/search/query?querytext=%27contentclass:sts_site%27

This API gives me all sub-sites of the root top level site:

https://{mycompany}.sharepoint.com/_api/search/query?querytext=%27*%27&trim&refinementfilters=%27contentclass:equals(%22STS_Web%22)%27

I'd like a single query which retrieves all sites and all of their subsites -- not just subsites of the root site.

dvdsmpsn
  • 231
  • 1
  • 3
  • 13