{"id":8678,"date":"2018-01-24T00:00:00","date_gmt":"2018-01-24T00:00:00","guid":{"rendered":"http:\/\/officedevblogs.wpengine.com\/?p=129"},"modified":"2018-01-24T00:00:00","modified_gmt":"2018-01-24T00:00:00","slug":"introducing-pnpjs-client-side-libraries-for-office365","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/introducing-pnpjs-client-side-libraries-for-office365\/","title":{"rendered":"Introducing PnPJS client-side libraries for Office 365"},"content":{"rendered":"<div id=\"body-content\">\n<p>The SharePoint Patterns and Practices Team is excited to announce the release of the <a href=\"https:\/\/pnp.github.io\/pnp\/\">Patterns and Practices Client-side Libraries<\/a>\u00a0(PnPJS).<\/p>\n<h2 id=\"office-365-cli\" class=\"code-line\" data-line=\"4\">Introduction<\/h2>\n<p>PnPJS is a fluent JavaScript API for consuming SharePoint and Office 365 REST APIs in a type-safe way.\u00a0You can use it with\u00a0SharePoint Framework, Nodejs, or JavaScript projects.\u00a0This an open source initiative complements existing SDKs provided by Microsoft offering developers another way to consume information from SharePoint and Office 365.<\/p>\n<h2 class=\"code-line\" data-line=\"6\">PnP Client Libraries<\/h2>\n<p class=\"code-line\" data-line=\"6\">There are nine packages included in the initial release. Each is linked to its specific documentation where you can find more details.<\/p>\n<ul>\n<li class=\"code-line\" data-line=\"6\"><a href=\"https:\/\/pnp.github.io\/pnp\/common\/index.html\">@pnp\/common<\/a>\u00a0&#8211;\u00a0Provides shared functionality across all pnp libraries<\/li>\n<li class=\"code-line\" data-line=\"6\"><a href=\"https:\/\/pnp.github.io\/pnp\/config-store\/index.html\">@pnp\/config-store<\/a>\u00a0&#8211;\u00a0Provides a way to manage configuration within your application<\/li>\n<li class=\"code-line\" data-line=\"6\"><a href=\"https:\/\/pnp.github.io\/pnp\/graph\/index.html\">@pnp\/graph<\/a>\u00a0&#8211;\u00a0Provides a fluent API for working with Microsoft Graph<\/li>\n<li class=\"code-line\" data-line=\"6\"><a href=\"https:\/\/pnp.github.io\/pnp\/logging\/index.html\">@pnp\/logging<\/a>\u00a0&#8211;\u00a0Light-weight, subscribable logging framework<\/li>\n<li class=\"code-line\" data-line=\"6\"><a href=\"https:\/\/pnp.github.io\/pnp\/nodejs\/index.html\">@pnp\/nodejs<\/a>\u00a0&#8211;\u00a0Provides functionality enabling the @pnp libraries within nodejs<\/li>\n<li class=\"code-line\" data-line=\"6\"><a href=\"https:\/\/pnp.github.io\/pnp\/odata\/index.html\">@pnp\/odata<\/a>\u00a0&#8211;\u00a0Provides shared odata functionality and base classes<\/li>\n<li class=\"code-line\" data-line=\"6\"><a href=\"https:\/\/pnp.github.io\/pnp\/pnpjs\/index.html\">@pnp\/pnpjs<\/a>\u00a0&#8211;\u00a0Rollup library of core functionality (mimics sp-pnp-js structure in previous version)<\/li>\n<li class=\"code-line\" data-line=\"6\"><a href=\"https:\/\/pnp.github.io\/pnp\/sp\/index.html\">@pnp\/sp<\/a>\u00a0&#8211;\u00a0Provides a fluent API for working with SharePoint REST<\/li>\n<li class=\"code-line\" data-line=\"6\"><a href=\"https:\/\/pnp.github.io\/pnp\/sp-addinhelpers\/index.html\">@pnp\/sp-addinhelpers<\/a>\u00a0&#8211;\u00a0Provides functionality for working within SharePoint add-ins<\/li>\n<\/ul>\n<h2 class=\"code-line\" data-line=\"10\">Usage<\/h2>\n<p>The libraries have interrelated peer dependencies, so you will need to install these as well as the primary package you wish to use. We will take as an example the task of getting a SharePoint web\u2019s title. First, we need to install the @pnp\/sp library as well as the libraries upon which it depends.<\/p>\n<pre>\nnpm install @pnp\/logging @pnp\/common @pnp\/odata @pnp\/sp --save\n\n<\/pre>\n<p>Next, we will import and use the functionality from @pnp\/sp within our application.<\/p>\n<pre>\n\/\/ get the sp variable from the library\n\/\/ this will serve as the root of our fluent chain\nimport { sp } from \u201c@pnp\/sp\u201d;\n\n\/\/ now get the web\u2019s title\nsp.web.select(\u201cTitle\u201d).get().then(w =&gt; {\n  console.log(`Title: ${w.Title}`);\n});\n\n<\/pre>\n<p>The above is a basic example of what is possible \u2013 please check out the\u00a0<a href=\"https:\/\/pnp.github.io\/pnp\/\">documentation<\/a> for more details on all of the included libraries.<\/p>\n<h2>Get involved<\/h2>\n<p>There are several ways to get involved in working on the PnPJS libraries and we encourage anyone who is interested to reach out. You can\u00a0<a href=\"https:\/\/pnp.github.io\/pnp\/getting-started-dev.html\">submit a pull request<\/a> to the <a href=\"https:\/\/github.com\/pnp\/pnp\/\">git repository<\/a>. We try and mark issues as help wanted when possible if you are looking for something to work on. Or join\u00a0<a href=\"https:\/\/aka.ms\/sppnp-js-sig-call\">SharePoint Framework and client-side dev bi-weekly community calls<\/a> where we cover topics related to these libraries as well as latest news on SharePoint framework, community demos, and other SharePoint Dev Patterns and Practices projects.<\/p>\n<h2>Feedback on the PnPJS libraries<\/h2>\n<p>We always appreciate feedback on our work, and with the launch of the PnPJS\u00a0libraries, we want to renew our push for community involvement. If you find issues, have suggestions, or would like to submit a feature please <a href=\"https:\/\/github.com\/pnp\/pnp\/issues\">open an issue<\/a>. You can also post on the\u00a0<a href=\"https:\/\/techcommunity.microsoft.com\/t5\/SharePoint-Developer\/bd-p\/SharePointDev\">Microsoft Tech Community SharePoint Dev channel<\/a> or reach out to us on twitter\u00a0<a href=\"https:\/\/twitter.com\/officedevpnp\">@officedevpnp<\/a> if you have questions.<\/p>\n<h2>What is SharePoint Patterns and Practices?<\/h2>\n<p><a href=\"http:\/\/aka.ms\/sppnp\">SharePoint Patterns and Practices (PnP)<\/a>\u00a0is an open source initiative coordinated by SharePoint engineering. It&#8217;s a channel for the SharePoint engineering to share documentation, guidance, samples and reusable component for the community. PnP initiative coordinates all SharePoint developer documentation and guidance across on-premises and online. Day to day work is coordinated by the PnP Core team, which consists of Microsoft internal people and external MVPs. If you have any input or feedback around SharePoint developer guidance, don&#8217;t hesitate to start a discussion with the team at Microsoft Tech Community site at <a href=\"http:\/\/aka.ms\/sppnp-community\">http:\/\/aka.ms\/sppnp-community<\/a>.<\/p>\n<p><span style=\"font-size: large\"><em>\u201cSharing is caring\u201d<\/em><\/span><\/p>\n<hr \/>\n<p><i>Patrick Rodgers, Senior Program Manager, Microsoft &#8211; 24th of\u00a0January 2018<\/i><\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>The SharePoint Patterns and Practices Team is excited to announce the release of the Patterns and Practices Client-side Libraries\u00a0(PnPJS).\u00a0<\/p>\n","protected":false},"author":69078,"featured_media":25159,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-8678","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-microsoft-365-developer"],"acf":[],"blog_post_summary":"<p>The SharePoint Patterns and Practices Team is excited to announce the release of the Patterns and Practices Client-side Libraries\u00a0(PnPJS).\u00a0<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/8678","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/users\/69078"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/comments?post=8678"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/posts\/8678\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/media\/25159"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/media?parent=8678"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/categories?post=8678"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/microsoft365dev\/wp-json\/wp\/v2\/tags?post=8678"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}