By Wallace Breza
We are pleased to announce the availability of the Power BI Embedded SDK for Node JS. The Node JS SDK is open source and available on GitHub at https://github.com/Microsoft/PowerBI-Node. The SDK is targeted for developers interested in leveraging Power BI Embedded within their own products and applications.
By utilizing the SDK, developers can easily access the Power BI Embedded REST APIs, generate app tokens for managing workspace collections, and manage workspace content including imports, datasets, and workspaces.
Example Usage
App Tokens
All calls through the SDK are authorized by an app token. The SDK includes built in support to generate app tokens based on API usage. The app tokens are signed using the access key that is generated when you create your workspace collection in Azure.
App tokens are HMAC signed JSON web tokens with custom claims based on intended usage. The default token expiration of tokens generated via the SDK is 1 hour, which it can be modified as needed.
To learn more about the app token flow, refer to our Azure documentation. Detailed SDK usage and example can be found on our GitHub page.
Provision Tokens
Provision tokens are used to manage the root of your workspace collection.
Required Claims
-
wcn – <WorkspaceCollectionName>
Dev Tokens
Dev tokens are used to make read/write scoped calls into a workspace within your collection.
Required Claims
-
wcn – <WorkspaceCollectionName>
-
wid – <WorkspaceId>
Embed tokens
Embed tokens are used to provide read-only access to a report and are required to embed your reports into applications.
Required Claims
-
wcn – <WorkspaceCollectionName>
-
wid – <WorkspaceId>
-
rid – <ReportId>
Command Line Interface
In addition to the SDK, we are also providing a sample Node command line tool demonstrating how to manage your Power BI Embedded workspace collections.
Integrated Help
Command Specific Help
The command line tool shows provisioning workspaces, uploading PBIX files, changing datasource credentials, listing reports and much more.
Example Import flow
The following is a common workflow example to create new workspace, import a PBIX file created from Power BI Desktop, and retrieve the datasets created from the import.
Create workspace
Import PBIX File
Get Datasets
This CLI tool is a great reference application for the Node SDK. The command line tool internally depends on the SDK to call into the Power BI Embedded REST APIs. The CLI tool is also available on Github at https://github.com/Microsoft/PowerBI-Cli.
What’s next?
We are continuing to improve all aspects of Power BI Embedded. You can share your ideas with us at https://ideas.powerbi.com.