spacer
Skip to content

@pnp/graph/sites

The search module allows you to access the Microsoft Graph Sites API.

Selective Imports Banner

Call graph.sites

import { graphfi } from "@pnp/graph";
import "@pnp/graph/sites";

const graph = graphfi(...);

const sitesInfo = await graph.sites();

Call graph.sites.getById

import { graphfi } from "@pnp/graph";
import "@pnp/graph/sites";

const graph = graphfi(...);

const siteInfo = await graph.sites.getById("{site identifier}")();

Call graph.sites.getByUrl

Using the sites.getByUrl() you can get a site using url instead of identifier

import { graphfi } from "@pnp/graph";
import "@pnp/graph/sites";

const graph = graphfi(...);
const sharepointHostName = "contoso.sharepoint.com";
const serverRelativeUrl = "/sites/teamsite1";
const siteInfo = await graph.sites.getByUrl(sharepointHostName, serverRelativeUrl)();

Make additional calls or recieve items from lists

We don't currently implement all of the available options in graph for sites, rather focusing on the sp library. While we do accept PRs to add functionality, you can also make calls by path.